I need to display text in an iPhone application, something like the way a book is displayed, for example:
How would I go about doing that? I've found the UITextView and UITextField and UIScrollView objects, but I can't figure out how to use them properly... Any suggestions?
I hope that makes sense...
You could use HTML in a UIWebView. Or layout a view with multiple UILabels set for particular fonts/sizes/properties. Then use a UITextField for the rest of the unformatted text. In desktop cocoa you can use attributed strings, but I don't think those are available for the iphone.
As Ryan said, you can use HTML with a WebView, but if you want to stick to native text drawing, you're going to have to drop down to CoreGraphics and draw all the text by hand. This is a lot of work, but if done right it will be more efficient and have a lower memory footprint than using WebView.
Edit: just took a look at your requirements again, and if only the heading and subheading require style changes, then I would recommend just using separate UILabels for those. You can also call -sizeToFit on the UILabels after assigning their text/font properties so they'll fit their text, which will let you handle wrapped headers/subheaders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With