How to change tab bar item text color

前端 未结 12 1977
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 05:36

\"enter

How can I change the color of \"More..\" text in tabbar to match with its icon

12条回答
  •  星月不相逢
    2020-12-13 06:18

    This is the swift version :-

            for item in self.mainTabBar.items! {
    
              let unselectedItem: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()]
              let selectedItem: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()]
              item.setTitleTextAttributes(unselectedItem as? [String : AnyObject], forState: .Normal)
              item.setTitleTextAttributes(selectedItem as? [String : AnyObject], forState: .Selected)
    
            }
    

    Or you can simply change in Appdelegate :-

     func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.blueColor()], forState: .Selected)
        UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.blackColor()], forState: .Normal)
        // Override point for customization after application launch.
        return true
    }
    

提交回复
热议问题