how to change tabBar icon color in ios

。_饼干妹妹 提交于 2019-11-28 12:18:14

This accomplishes what you're asking for:

[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
[[UITabBar appearance] setAlpha:0.25];

In Swift on iOS8 it would be:

UITabBar.appearance().tintColor = UIColor.redColor()

The answers here aren't quite what I was looking for. It makes sense if you want a generic change to the color of all tab bar controllers in your app, but realistically, you don't necessarily want to make such a global change (not to mention that it can be difficult to debug and find later). It's better to be more focused, so you want to change the color directly.

As of iOS 8, you need to change the tintColor property of the tab bar. Hopefully, you're subclassing your UITabBarController. If you are, you can set the color in viewDidLoad:

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tabBar.tintColor = [UIColor grayColor];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!