changing font size of UIButton
I have a UIButton
which displays a text, with the following code:
[button setTitle:@"Join this group" forState:UIControlStateNormal];
however, how do I change the开发者_JAVA百科 font size for this? I tried
button.titleLabel.font = [UIFont fontWithName:@"Arial-MT" size:8.0];
but I think it's a totally different thing. Or at least how do I make the text to adjust to the size of the button frame. Should I just use textLabel.text instead?
The reason that the code you're posting isn't working is probably because Arial isn't present in iOS. You can change the properties of a UIButton
's titleLabel
just like any other instance of UILabel
. Read about that here.
So, you can change the font size with something like:
button.titleLabel.font = [UIFont systemFontOfSize:14.0];
You can choose a font by name, but not all fonts are available on iOS. Here's a list of ones that are.
精彩评论