nul*_*ull 207
试试以下内容:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setBarTintColor:[UIColor yellowColor]];
Run Code Online (Sandbox Code Playgroud)
要为非活动按钮着色,请将以下代码放入VC中viewDidLoad:
UITabBarItem *tabBarItem = [yourTabBarController.tabBar.items objectAtIndex:0];
UIImage *unselectedImage = [UIImage imageNamed:@"icon-unselected"];
UIImage *selectedImage = [UIImage imageNamed:@"icon-selected"];
[tabBarItem setImage: [unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem setSelectedImage: selectedImage];
Run Code Online (Sandbox Code Playgroud)
您需要为所有的tabBarItems做到这一点,是的,我知道这是丑陋的,希望有会来做到这一点更清洁的方式.
迅速:
UITabBar.appearance().tintColor = UIColor.red
tabBarItem.image = UIImage(named: "unselected")?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = UIImage(named: "selected")?.withRenderingMode(.alwaysOriginal)
Run Code Online (Sandbox Code Playgroud)
小智 22
有一种更容易的方法来做到这一点.
只需打开文件检查器并选择"全局色调"即可.
您还可以在Interface Builder中设置应用程序的色调颜色."文件"检查器的"界面生成器文档"部分中的"全局色调"菜单允许您打开"颜色"窗口或选择特定颜色.
另见:
Öme*_*alı 18
iOS 7.1.1
如果有人需要使用全局设置色调颜色:
[[UIView appearance] setTintColor:[UIColor whiteColor]];
Run Code Online (Sandbox Code Playgroud)
在didFinishLaunchingWithOptions的AppDelegate.
以下代码将在任何viewDidLoad方法中仅更改标签栏色调颜色:
[self.tabBarController.tabBar setTintColor:[UIColor redColor]];
Run Code Online (Sandbox Code Playgroud)
在app delegate didFinishLaunchingWithOptions:
window.tintColor = [UIColor purpleColor];
Run Code Online (Sandbox Code Playgroud)
为应用程序全局设置色调颜色.
将其写入Tab栏的View Controller类:
// Generate a black tab bar
self.tabBarController.tabBar.barTintColor = [UIColor blackColor];
// Set the selected icons and text tint color
self.tabBarController.tabBar.tintColor = [UIColor orangeColor];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
102628 次 |
| 最近记录: |