0

I would like to develop a text editor app in iOS for iPad. I need some features like syntax coloring and auto-completion. I am thinking about making my own subclass of UIView or UIControl. I would like to know where to start painting the text with different colors. If I override the drawRect function, will I have any performance issue? I mean that I can draw text in drawRect with NSString's UIKit addition, such as drawInRect. If it is really required to use other techniques for text rendering, where shall I start?

jscs
  • 63,694
  • 13
  • 151
  • 195
Richard Dong
  • 704
  • 1
  • 7
  • 13

1 Answers1

-1

In general you want to avoid overriding drawRect. It does tend to cause reduced performance. Better to use system objects and let them take care of the rendering.

Apple has started adding support for attributed strings to view objects like UITextView. You could probably come up with a way to use a UITextView to display your styled/colored text.

Failing that yo'll probably have to use the CoreText framework.

Duncan C
  • 128,072
  • 22
  • 173
  • 272