Search code examples
objective-cios5xcode4.2

How to change the color of a specific word in ios


I want to change the color of a particular word from a sentence in IOS 5. Let my string be NSString str = @"Your password is abc"; I want to change the color of password 'abc'. Please help me.

Thanks in advance.


Solution

  • In IOS 6 you could change the font, textColor, and textAlignment for particular word through attributedText you could find the documentation for this here

    http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextView_Class/Reference/UITextView.html

    Same question is answered in stackoverflow the link of the question is as follows

    Bold & Non-Bold Text In A Single UILabel?