如何definitiveley设置UITabBar背景颜色和UITabBar色彩 [英] How to definitiveley set UITabBar background color and UITabBar tint color

查看:153
本文介绍了如何definitiveley设置UITabBar背景颜色和UITabBar色彩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图将UITabBar的色彩和背景颜色设置好一段时间,似乎没有任何效果。
到目前为止,我尝试过:

I have been trying to set my UITabBar's tint color and background color for quite some time now and nothing seems to work. So far I have tried:

tabBarController?.tabBar.backgroundColor = UIColor.orangeColor()
tabBarController?.tabBar.barTintColor = UIColor.whiteColor()

以及:

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

这些似乎都没有对我的标签栏产生任何影响。我还想提一下,我在导航控制器中嵌入了VC,我设置的全局色调颜色完全正常。

Neither of these seemed to have any effect on my tab bar. I'd also like to mention that I have the VC embedded in a navigation controller for which the global tint color that I set works perfectly fine.

推荐答案

如果你想隐式设置tabbar的色调和barTint颜色然后在你的 Appdelegate.swift 中,

If you want to set tabbar's tint and barTint color implicitly then in your Appdelegate.swift,

    UITabBar.appearance().barTintColor = UIColor.orangeColor()
    UITabBar.appearance().tintColor = UIColor.greenColor()

如果你想设置tabbar的色调和barTint颜色对于特定的viewController然后在 ViewController.swift

If you want to set tabbar's tint and barTint color for specific viewController then in ViewController.swift,

 self.tabBarController?.tabBar.tintColor = UIColor.orangeColor()
 self.tabBarController?.tabBar.barTintColor = UIColor.greenColor()

这篇关于如何definitiveley设置UITabBar背景颜色和UITabBar色彩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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