I have the following code for setting up text in a UIButton
[self.fullListButton_ setTitle:[NSString stringWithFormat:@"%d", [self.newsfeedItem_.newsfeedToSubjects count] - 3] forState:UIControlStateNormal];
The issue is I can't seem to set the font for this. How do I do so?
To set a different font on UIButton programmatically you will need to create a new instance of UIFont object. The initializer of UIFont accepts two arguments: name and size. where the “GillSans-Italic” is a font name you want to set.
Go to Settings > Accessibility > Display & Text Size. Adjust any of the following: Bold Text: Display the text in boldface characters. Larger Text: Turn on Larger Accessibility Sizes, then adjust the text size using the Font Size slider.
Go to Settings > Display & Brightness, then select Text Size. Drag the slider to select the font size you want.
To change the font size of a button, use the font-size property.
In the newer version of iOS:
UIButton * myButton;
myButton.titleLabel.font = [UIFont systemFontOfSize: 12];
Or any other font mechanism.
Look here for the UIButton portions:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIButton_Class/UIButton/UIButton.html#//apple_ref/occ/instp/UIButton/titleLabel
And here for the UIFont stuff:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIFont_Class/Reference/Reference.html
In your code:
self.fullListButton_.titleLabel.font = [UIFont systemFontOfSize: 12];
or
self.fullListButton_.titleLabel.font = [UIFont fontWithName:@"Arial" size:12];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With