how to change UITabbar selected color?

后端 未结 4 1469
礼貌的吻别
礼貌的吻别 2020-12-18 14:02

according to this post for now, Is apple will also reject this code?

and how to implement what apple will approve?

@interface UITabBar (ColorExtensi         


        
4条回答
  •  囚心锁ツ
    2020-12-18 15:02

    for iOS 10 (or higher):

    To set selected color just set:

    let tabBarAppearace = UITabBar.appearance()
    tabBarAppearace.tintColor = UIColor.nowYouBlue
    

    Above will work for all iOS version currently supported, but to change unselected color:

        if #available(iOS 10.0, *) {
            tabBarAppearace.unselectedItemTintColor = UIColor.red
        } else {
            // Fallback on earlier versions
        }
    

    Above code will look like this on iOS 10.

提交回复
热议问题