开发者

Tips on implementing a custom UITextView interface on the iPhone?

I am trying to implement a control to edit text that will display the text in multiple colors. None of the solutions I have attempted yet have b开发者_Python百科een good enough.

  1. UITextView cannot accomplish this. All of the text must be the same color.
  2. Using CoreGraphics to draw the text does not allow the text to be selected.
  3. Using a UIWebView, DIV and PRE tags cannot be set to contentEditable on Mobile Safari.
  4. Currently playing with using an off-screen TEXTAREA and an on-screen DIV to show the rendered text. This works pretty well, except supporting all of these at the same time seems impossible: click-to-type, click-to-move-cursor, click-and-hold-select/copy/paste.

Anyone have any tips on this predicament?

I've been trying to find any preexisting library out there that will accomplish this in a good way, to no luck. I'm open to any ideas!


Well, just pulling an idea out of my... let's say hat.

Could you put a transparent UITextfield over a view that draws the text? If the background was clear and the text color was clear the user could not perceive it but it should still respond to all commands. As the user enters and edits text you could draw the results on the view underneath.

I think the selection would work without any modification at all. When the user selected the clear text, it should create the illusion of selecting the drawn text automatically.


Like this one? StyledText http://three20.info/gfx/overview/styledtext.png It's in Three20 .


Here is an idea. I have no idea if it would work.

If you are only using colors, and not styles, the a UIWebView with colored text might layout text in exactly the same way as a UITextView. You could put a UITextView with invisible ink (text and background fully transparent) over a UIWebView and mirror the contents with colors in the html. I assume you can do scrolling with javascript along with the colored layout.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜