Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting UIButton font

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?

like image 513
xonegirlz Avatar asked Jul 11 '12 23:07

xonegirlz


People also ask

How do I change font size in UIButton?

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.

How do I change the font on my Iphone 13?

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.

How do I change the font size on my Iphone 11?

Go to Settings > Display & Brightness, then select Text Size. Drag the slider to select the font size you want.

How do I change the font on my button text?

To change the font size of a button, use the font-size property.


1 Answers

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];
like image 50
trumpetlicks Avatar answered Oct 11 '22 03:10

trumpetlicks