Search code examples
iphoneiosnsstringuitextfielditalics

Make portion of NSString italicized or bold, not whole string


How would I go about italicizing a single word in an NSString which will be displayed in a UILabel? Specifically, I don't want all text to be italicized, just one word.

Thanks!

(Edited) I meant UILabel, not UITextField.


Solution

  • I don't think that what you are asking to do is possible (I'd be happy to be proven wrong). However, this library (https://github.com/facebook/three20/) is a popular way to achieve the same result in a UILabel (not text field) . The library works fairly well, but does have a lot of limitations, especially on edge conditions, and of course, it comes with associated overhead.

    I'd encourage you to think about other ways of achieving the same user outcome. Can Placeholder text help? How about hints next to your text field?

    Good luck.