IPhone Developer
IPhone Developer

Reputation: 25

To make the selected part of a UILabel as Bold

I have two UILabels, both will have the dynamic text but interrelated. for example:

label1.text=@"Abc";
label2.text=@"Meaning of Abc is ......";

Now label2 will always have label1.text plus some extra text.

I want to make this part in label2 to be in Bold.

So far I found that it could be done by drawing the text in drawRect but that seems to be very complicated.

Is there any other way out is possible??

Thanks

Ben

Upvotes: 0

Views: 560

Answers (1)

Hampus Nilsson
Hampus Nilsson

Reputation: 6822

iOS 6 will supported attributed label for this sort of thing. Until then or if iOS 5=< compatibility is important to you, you can make the label a UIWebView and use HTML markup. Or do it the hard way with drawRect (which will perform better).

Edit: There are third party libraries that add attributed labels, Nimbus is one of them that works well.

Upvotes: 1

Related Questions