簡體   English   中英

UIButton自定義字體未顯示

[英]UIButton Custom Font not showing

我認為我已經檢查了其他類似的問題,並完成了其中列出的內容,但是我的自定義字體仍未顯示在UI按鈕上。

該字體在項目中,並且可以正確顯示在我的UITableViewCells中,因此我知道該字體可以正常工作。

我正在加載視圖,並將字體分配給按鈕,但是當我運行應用程序時,它沒有顯示正確的字體。

FirstViewController.h

@interface FirstViewController : UIViewController <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource> {
    ...    
    UIButton *searchButton;
    ...
}

...
@property (nonatomic, retain) IBOutlet UIButton *searchButton;
...

@end

然后我在FirstViewController.m中得到了這個

@synthesize searchButton;

- (void)viewDidLoad
{
    [super viewDidLoad];    

    self.searchButton.titleLabel.font = [UIFont fontWithName: @"FontFile" size: 11.0 ];
}

我做錯了什么?

[self.searchButton setTitle:@"ButtonTitle" forState:UIControlStateNormal];

正如jamihash所指出的那樣,我沒有將按鈕從IB連接到代碼。 這樣做解決了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM