我在didFinishLaunchingWithOptions:
下的AppDelegate.m文件中有此代码,因此我可以使用自定义字体。
[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor grayColor], UITextAttributeTextColor,
[UIFont fontWithName:@"Gotham-Medium" size:10], UITextAttributeFont, nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIFont fontWithName:@"Gotham-Medium" size:10], UITextAttributeFont, nil] forState:UIControlStateHighlighted];
字体更改按预期工作,但我在调试控制台中获得此输出:
button text attributes only respected for UIControlStateNormal, UIControlStateHighlighted and UIControlStateDisabled. state = 1 is interpreted as UIControlStateHighlighted.
答案 0 :(得分:5)
将UIControlStateHighlighted
更改为UIControlStateSelected