tags:

views:

83

answers:

2

I have a UILabel which contains textvalue and i want to bold a particular character in that whole string so please let me inform is it possible? and yes then please give me some example it really important for me.Please help me.

A: 

Sorry, can be done in 3.2 (and higher) with NSAttributedString. But not in the iPhone as it exists today.

Kendall Helmstetter Gelner
ok but can you give me some code that can do particular character bold.
Ankit Vyas
Sorry, don't have any offhand - you'll have to look for NSAttributedString examples.
Kendall Helmstetter Gelner
A: 

It's possible as single-line label if you create a custom UIView subclass, and implement the -drawRect: like this:

-(void)drawRect:(CGRect)rect {
   NSString* stringBefore;
   NSString* boldPart;
   NSString* stringAfter;
   UIFont* normalFont;
   UIFont* boldFont;
   ...
   CGSize sizeBefore = [stringBefore drawAtPoint:CGPointZero withFont:normalFont];
   CGSize sizeBold = [boldPart drawAtPoint:CGPointMake(sizeBefore.width, 0) withFont:boldFont];
   [stringAfter drawAtPoint:CGPointMake(sizeBefore.width+sizeBold.width, 0) withFont:normalFont];
}
KennyTM
Ya man!i think it will work,great job but still i want some easier way if possible!.Thanks a lot!
Ankit Vyas