I've checked out the other similar questions and done what's listed in those, I think, but my custom font is still not showing on a UI button.
The font is in the project, and it is appearing correctly in my UITableViewCells, so I know the font works fine.
I'm loading the view, and assigning the font to the button, but when I run the app it's not showing up the correct font.
FirstViewController.h
@interface FirstViewController : UIViewController <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource> {
...
UIButton *searchButton;
...
}
...
@property (nonatomic, retain) IBOutlet UIButton *searchButton;
...
@end
Then I've got this in FirstViewController.m
@开发者_如何学JAVAsynthesize searchButton;
- (void)viewDidLoad
{
[super viewDidLoad];
self.searchButton.titleLabel.font = [UIFont fontWithName: @"FontFile" size: 11.0 ];
}
What have I done wrong?
[self.searchButton setTitle:@"ButtonTitle" forState:UIControlStateNormal];
As jamihash pointed out, I hadn't hooked up the button from IB to the code. Doing that fixed it.
精彩评论