-2

How to get the font style of UILabel? Whether it is Bold or italic ?

teriiehina
  • 4,741
  • 3
  • 41
  • 63
Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56
  • Check here and you will get some idea [FontStyle](http://stackoverflow.com/questions/15294179/select-bold-and-italicized-text-from-textfield) – Anoop Vaidya Apr 02 '13 at 17:27

4 Answers4

5

You will need to inspect the font name.

myLabel.font.fontName

http://developer.apple.com/library/ios/documentation/uikit/reference/UIFont_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006891-CH4-SW16

Chris Wagner
  • 20,773
  • 8
  • 74
  • 95
0

Try this one:

NSAttributedString *string=yourLabel.attributedText;
if ([[textFieldFontName rangeOfString:string] length] > 0){
    NSLog(@"Bold");
}
if ([[textFieldFontName rangeOfString:string] length] > 0){
    NSLog(@"Italic");
}

*Note if your string contains both then, this may not work

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
-1

Select your label in the interface builder (xib or storyboard) and go to the Attributes Inspector. There click on the "T" by font and then set font to Custom. Now you can change the font, size etc.

Bart
  • 55
  • 3
  • 9
-1
UILabel *myLabel;   
myLabel.font = [UIFont fontWithName:@"fontName" size:16.0];//set font according your choice
myLabel.font = [UIFont boldSystemFontOfSize:16.0];//bold font
myLabel.font = [UIFont systemFontOfSize:16.0];//system font

Hope it's helpful for you....

Chirag Pipaliya
  • 1,281
  • 12
  • 20