문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

A native UILabel does not support NSAttributedString which is what is normally used to display strings with formatting. You could try an output the text your self using Core Text but I would suggest checking out FontLabel or the three-20 project mentioned by @JJ Rohrer

Use NSAttributedString... Find controllers to draw NSAttributedString,since UILabel wont support NSAttributedString

Controller for NSAttributedString

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top