简体   繁体   中英

If I want formatted text but don't want to use UIWebView, is Core Text my only remaining option?

If I want formatted text (variations on size, position of certain text elements, etc) but don't want to use UIWebView, is Core Text my only remaining option?

I'm shying away from UIWebView primarily because of problems getting the layout right when switching between the iPad and the iPhone. Rather than doing conditional code and dynamically adjusting the HTML depending on device/orientation, I thought I would go ahead and look at using Core Text.

Suggestions?

Perhaps NSAttributedString could help your cause?

An NSAttributedString object manages character strings and associated sets of attributes (for example, font and kerning) that apply to individual characters or ranges of characters in the string. An association of characters and their attributes is called an attributed string. The cluster's two public classes, NSAttributedString and NSMutableAttributedString, declare the programmatic interface for read-only attributed strings and modifiable attributed strings, respectively.

Using only Apple's SDK, yes Core Text is your only other option. I am sure there are third-party implementations, and you could ask that question if you are interested. Apple has a decent example which shows both how to draw text using Core Text and how to handle keyboard input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM