How to change tab bar item text color

前端 未结 12 1932
没有蜡笔的小新
没有蜡笔的小新 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:03

    For a swift solution, let type inference be your friend:

    override func viewWillAppear(animated: Bool) {
      for item in self.tabBar.items! {
        let unselectedItem = [NSForegroundColorAttributeName: UIColor.blackColor()]
        let selectedItem = [NSForegroundColorAttributeName: UIColor.whiteColor()]
    
        item.setTitleTextAttributes(unselectedItem, forState: .Normal)
        item.setTitleTextAttributes(selectedItem, forState: .Selected)
      }
    }
    

提交回复
热议问题