Default tab bar item colors using swift Xcode 6

前端 未结 4 623
执念已碎
执念已碎 2020-12-01 00:59

Environment: - Xcode 6 beta 4 - Swift language - iOS Tabbed Application (default xCode project)

How can I change the default grey color of the tabs to something else

4条回答
  •  天涯浪人
    2020-12-01 01:49

    I don't have enough reputation for commenting the comments, but many are interested how to change the color of selected image

    just add another if let check after

    if let image = item.image
    

    just like this:

    if let selectedImage = item.selectedImage {
                item.selectedImage = selectedImage.imageWithColor(UIColor.yellowColor()).imageWithRenderingMode(.AlwaysOriginal)
            }
    

    this solved the problem perfectly. And a little addition, since Swift 1.2 and Xcode 6.3.2 you need

    for item in self.tabBar.items as! [UITabBarItem]
    

    instead of

    for item in self.tabBar.items as [UITabBarItem]
    

    Hope that helps!

提交回复
热议问题