how to change disabled item color in TabBar in swift 3?

跟風遠走 提交于 2019-12-12 18:02:13

问题


I have a TabBar in my project and when user select item this item will disable but the color will change too! I want the color is same as other items color in TabBar I used

item.isEnabled = false

for disable item but this codes here won't work for this item

 override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    self.tabBar.barTintColor = UIColor.init(red: 126/255, green: 0/255, blue: 64/255, alpha: 1.0)
    if #available(iOS 10.0, *) {
        self.tabBar.unselectedItemTintColor = UIColor.white
        self.tabBar.unselectedItemTintColor = UIColor.white

    } else {
        // Fallback on earlier versions
    }
    UITabBar.appearance().tintColor = UIColor.white

}

回答1:


Try this code -

UITabBar.appearance().tintColor = UIColor.gray
UITabBar.appearance().unselectedItemTintColor = UIColor.gray

Hope this helps!



来源:https://stackoverflow.com/questions/45409413/how-to-change-disabled-item-color-in-tabbar-in-swift-3

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