任何人都可以帮我解决这个奇怪的问题,无论如何都要将uitabbar项目的文本颜色从默认灰色更改为白色,将所选颜色更改为蓝色.
ban*_*isa 75
老问题,但我有一个新的答案,在iOS 5以后支持(我也使用LLVM 4.0文字)
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] }
forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor blueColor] }
forState:UIControlStateSelected];
Run Code Online (Sandbox Code Playgroud)
Eik*_*ike 11
UITextAttributeTextColor从iOS版7.使用过时NSForegroundColorAttributeName代替.
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor blackColor] }
forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
在斯威夫特
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.blackColor()], forState: .Normal)
Run Code Online (Sandbox Code Playgroud)
从 iOS 10 开始,可以unselectedItemTintColor在UITabBar.
tintColor的颜色大于UITabBar所选项目的颜色。
如果您想为任何项目设置唯一值,您还可以直接与和tabBarItem.titleTextAttributes(for:)组合在该项目上设置(前面提到的)。tabBarItem.imagetabBarItem.selectedImage
| 归档时间: |
|
| 查看次数: |
24191 次 |
| 最近记录: |