user494461
user494461

Reputation:

how to change the colour of a certain sentence in IOS UILabel?

Suppose I have text like this in a label

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

How do I change the colour of the the sentence "At vero eos et..." starting in the second line?

Upvotes: 0

Views: 159

Answers (2)

Josh Rosen
Josh Rosen

Reputation: 1686

I don't believe this is possible with the UILabel class. However, it wouldn't be too hard to do this with some simple HTML in a UIWebView.

[myWebView loadHTMLString:@"Some normal text. <font color=\"red\">Some red text.</font>" baseURL:nil]

Let me know if this works well for you.

Upvotes: 1

mattjgalloway
mattjgalloway

Reputation: 34912

You can't do that with a standard UILabel. You'd either have to use multiple UILabels or take a look at CoreText which would also do what you want - http://developer.apple.com/library/mac/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html.

Upvotes: 1

Related Questions