1
我在我的AppDelegate.m文件中的這個代碼didFinishLaunchingWithOptions:
下,這樣我就可以有一個自定義字體。UITabBarItem外觀UIControlStateHighlighted
[[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.
這做到了。謝謝! –
記住+1並檢查 –
剛剛做到了。謝謝 –