MANGA
MANGA

Reputation: 27

is it possible to make text in the UILabel different colour?

Is it possible to make some text in the same UILabel in different colour and different size?

I want it different colour in the same label, is it possible? I mean in one label have many colour of text,

Upvotes: 0

Views: 642

Answers (3)

Cœur
Cœur

Reputation: 38757

Since iOS6, you can use the attributedText property of the UILabel to achieve multi colours.

Upvotes: 0

TechZen
TechZen

Reputation: 64428

You change the text color like this:

myLabel.textColor=[UIColor blueColor];

You change font like:

myLabel.font= aFont; //a font object you've previously defined.

See UILabel Class Reference.

Edit01: Upon rereading, it appears the OP wants to change text attributes within the same string. In that case, you will need to use CFAttributedString. I haven't used it but I believe it works on the iPhone.

Upvotes: 0

David Dunham
David Dunham

Reputation: 8339

iPhone doesn't have NSAttributedString, and it's pretty obvious that UILabel doesn't have a way to specify per-character attributes. So I think your only answer is to use WebKit (UIWebView).

Upvotes: 1

Related Questions