但是,這適用於我(與簡單的BarButtonItem),剛剛測試它:
[self.myBarButtonItem setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Helvetica" size:22.0],NSFontAttributeName,
nil]forState:UIControlStateNormal];
對於使用外觀代理,你可以試試這個:
NSDictionary *attrDict = [NSDictionary dictionaryWithObject: [UIFont fontWithName:@"Helvetica" size:22.0] forKey: UITextAttributeFont];
[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
forState: UIControlStateDisabled];
[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
forState: UIControlStateNormal];
你肯定,你在你的AppDelegate
實現這個 - 類? (例如,在didFinishLaunchingWithOptions
- 方法)
並使用NSFontAttributeName與[外觀的UIBarButtonItem],但似乎並不工作 –
@PeterLapisu我」我編輯了我的答案 – falsecrypt