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.
views:
83answers:
2
A:
Sorry, can be done in 3.2 (and higher) with NSAttributedString. But not in the iPhone as it exists today.
Kendall Helmstetter Gelner
2010-04-29 04:56:45
ok but can you give me some code that can do particular character bold.
Ankit Vyas
2010-04-29 05:07:55
Sorry, don't have any offhand - you'll have to look for NSAttributedString examples.
Kendall Helmstetter Gelner
2010-04-29 15:06:18
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
2010-04-29 06:01:44
Ya man!i think it will work,great job but still i want some easier way if possible!.Thanks a lot!
Ankit Vyas
2010-04-29 06:52:50