UILabel: how do you set the font size?
[myView setFont:[UIFont systemFontOfSize:12]];
or
[myView setFont:[UIFont boldSystemFontOfSize:12]];
or for font family
[myView setFont:[UIFont fontWithName:@"Helvetica" size:12]];
If your UILabel
's font is defined in IB
storyboard
and you just want to increase size then this will work, worked for me ;)
[_label setFont: [_label.font fontWithSize: sizeYouWant]];
Or
[self.label setFont: [self.label.font fontWithSize: sizeYouWant]];
Another method as others says also worked:
[_label setFont:[UIFont systemFontOfSize:13.0]];
Check UIFont class. After that you'll probably get why you should use it like that:
[myView setFont:[UIFont systemFontOfSize:12]];
Remember that the user can globally set how large they want their text to be, so you shouldn't use a fixed font size like "12". Use the following fonts:
[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]
[UIFont preferredFontForTextStyle:UIFontTextStyleBody]
[UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1]
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2]
I think the default for UILabel is Caption1, the others will be bigger or smaller. And they will adapt if the user wants big text or small text on his or her device. (Font size 12 might actually bigger than the normal label size if the user picked a very small size).