在 iOS 7 上更改标签栏色调颜色 [英] Change tab bar tint color on iOS 7

查看:18
本文介绍了在 iOS 7 上更改标签栏色调颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将 iOS 7 上标签栏的色调从默认的带有蓝色图标的白色更改为带有不同颜色按钮的另一种颜色?

Is there a way to change the tint of a tab bar on iOS 7 from the default white with blue icons to another color tint with different color buttons?

推荐答案

试试下面:

[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setBarTintColor:[UIColor yellowColor]];

要为 非活动 按钮着色,请将以下代码放入 VC 的 viewDidLoad:

To tint the non active buttons, put the below code in your VC's 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];

您需要为所有 tabBarItems 执行此操作,是的,我知道这很丑,希望 有更清洁的方法来执行此操作.

You need to do this for all the tabBarItems, and yes I know it is ugly and hope there will be cleaner way to do this.

斯威夫特:

UITabBar.appearance().tintColor = UIColor.red

tabBarItem.image = UIImage(named: "unselected")?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = UIImage(named: "selected")?.withRenderingMode(.alwaysOriginal)

这篇关于在 iOS 7 上更改标签栏色调颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆