xonegirlz
xonegirlz

Reputation: 8967

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?

Upvotes: 17

Views: 24307

Answers (1)

trumpetlicks
trumpetlicks

Reputation: 7065

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];

Upvotes: 35

Related Questions