Question

I am developing an iPhone app and want to be able to use an NSMutableAttributedString inside a ScrollView. Here are the steps I want to follow:

  1. Grab a string from CoreData.
  2. Copy the string into an NSMutableAttributedString.
  3. Parse the string and modify the attributes of portions of the text.
  4. Display the NSMutableAttributedString inside a ScrollView.

How can I do this?

If I am reading the docs correctly, only CoreText naitively supports display of attributed strings on the iPhone. Is that correct? If so, how can I create a CoreText object when I don't know how the Y value for the CGRect?

Was it helpful?

Solution

Upon doing more research and experimentation, I found that there are methods available to calculate the size of the Rects used to draw CoreText. I looked at the code from http://github.com/jonasschnelli/I7CoreTextExample as a starting point for my project. Although there are a couple of bugs in the code, it does provide a good base understanding of how CoreText can be used.

By the way, although the code is set up to run on the iPad, the same code works on an iPhone. I hope this helps someone.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top