我正在开发一个应用程序,在其中调用了UITextFieldDelegate方法:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { }
我成功地调用了它,并且在方法内,我启用了一个特定的按钮,这也很好地起作用。然而,我面临的问题是,当按钮可用时,我无法使按钮上的标题加粗。我在接口构建器中设置了字体,并试图以编程方式使标题加粗。以下是相关代码,显示了我正在做的事情:
if ([keys count] == [_tireName count]) {
[_doneButton setEnabled:YES];//this line works
[[_doneButton titleLabel] setFont:[UIFont boldSystemFontOfSize:28]];//this line does nothing
} else if ([keys count] < [_tireName count]){
[_doneButton setEnabled:NO];//this line works
[[_doneButton titleLabel] setFont:[UIFont systemFontOfSize:28]];//this line does nothing
}
忽略 "if" 从句本身。我想要当按钮启用时按钮上的文本为粗体,当它被禁用时,按钮上的文本应该是“正常”的。我做错了什么?