31 iphone xcode uitabbarcontroller ios
嗨,我有这个代码,它不起作用,我做错了什么?
- (void)viewDidLoad
{
[self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont, nil] forState:UIControlStateDisabled];
}
Run Code Online (Sandbox Code Playgroud)
顺便说一句,这不是我的viewDidLoad中唯一的东西,但我只是想告诉你那些我把它放在哪里.
Chr*_*hey 67
根据:如何在iOS 5中更改UITabBarItem中的文本颜色
看起来解决方案可能是将消息发送到外观代理,而不是一个项目:
(在iOS 7.0+中已弃用)
[[UITabBarItem appearance] setTitleTextAttributes:@{UITextAttributeFont: [UIFont fontWithName:@"AmericanTypewriter" size:20.0f]} forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
对于iOS 7.0+,请使用:
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"AmericanTypewriter" size:20.0f]} forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
Wuj*_*ujo 11
快速的方式,懒惰:
UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont.systemFontOfSize(10)], forState: .normal)
UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont.systemFontOfSize(10)], forState: .selected)
Run Code Online (Sandbox Code Playgroud)
小智 5
雨燕3
UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name: "OpenSans", size: 10)!], for: .normal)
Run Code Online (Sandbox Code Playgroud)
Swift 4.1和自定义字体
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont(name: "Montserrat-Medium", size: 11)], for: .normal)
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont(name: "Montserrat-Medium", size: 11)], for: .selected)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19429 次 |
| 最近记录: |