How to highlight CoreText with changing highlight colors?

Your basic idea isn't too bad for highlighting. I don't know if it's really easier than just highlighting the glyphs while you draw, but it's not a bad idea, and makes it easy to turn on and off highlighting, so that's pretty nice Rather than creating lots of views, put your Core Text onto a CALayer instead. Then you can create additional highlighting layers to put over the text.

This keeps everything inside of a single view. Layers are much cheaper than views. If you're just trying to do "highlighter" style highlighting, then you can just set the backgroundColor and frame for the layers and you're done.

Your basic idea isn't too bad for highlighting. I don't know if it's really easier than just highlighting the glyphs while you draw, but it's not a bad idea, and makes it easy to turn on and off highlighting, so that's pretty nice. Rather than creating lots of views, put your Core Text onto a CALayer instead.

Then you can create additional highlighting layers to put over the text. This keeps everything inside of a single view. Layers are much cheaper than views.

If you're just trying to do "highlighter" style highlighting, then you can just set the backgroundColor and frame for the layers and you're done.

Thanks, Rob! I'll look into switching to using CALayers. I have no experience with them.Do you know of a good resource/book to learn how to use them?

Also, do you know of a way to tell a viewcontroller when a subview is done drawing? – jschmidt Jul 25 at 15:32 What do you mean by "done drawing?" All UIKit drawing is done on the main thread.

You can pre-calculate everything on a background thread if you need to and let your View Controller know that the calculations are done. But you have to do UIKit drawing on the main thread. CALayer can draw on background threads if you right your code correctly.

For an intro to CALayer, see developer.apple. Com/library/ios/#documentation/Cocoa/Conceptual/…. And of course when it comes out later this year, you can see my book for extensive discussion :D – Rob Napier Jul 25 at 16:53 Thanks again for the info.

What is the name of the book you are writing and the publisher? I'll keep an eye out for it. Maybe I'm not using the right terminology.

My problem is that my code in the ViewController calls CoreTextView setNeedsDisplay after loading a new string for the CoreTextView to draw. When the view is done drawing, I want the ViewController to be notified. Perhaps I should move the drawRect code to a different method like "drawText:" and then call that instead of setNeedsDisplay?

Then on drawRect: I can also call "drawText"? I feel like I'm missing something fundamental. – jschmidt Jul 25 at 20:07 When you call setNeedsDisplay, the system will draw at the end of the current event loop.

You can use self performSelector:withObject:afterDelay:0 (delay=0) to schedule something for "the next event loop" which will always be after the view is drawn, provided you're keeping your own code on the main thread. My book will be Pushing the Limits with iOS 5 Programming from Wiley.Wiley.Com/WileyCDA/WileyTitle/productCd-1119961327. Html – Rob Napier Jul 25 at 20:13 Thank you so much, Rob.

I'll definitely buy the book when it comes out! I'll have to modify my code a bit, but you've definitely helped! – jschmidt Jul 257 at 0:03.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions