Change tab bar item selected color in a storyboard
In Swift, using xcode 7 (and later), you can add the following to your AppDelegate.swift file:
UITabBar.appearance().tintColor = UIColor(red: 255/255.0, green: 255/255.0, blue: 255/255.0, alpha: 1.0)
This is the what the complete method looks like:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// I added this line
UITabBar.appearance().tintColor = UIColor(red: 255/255.0, green: 255/255.0, blue: 255/255.0, alpha: 1.0)
return true
}
In the example above my item will be white. The "/255.0" is needed because it expects a value from 0 to 1. For white, I could have just used 1. But for other color you'll probably be using RGB values.
This elegant solution works great on SWIFT 3.0, SWIFT 4.2 and SWIFT 5.1:
On the Storyboard:
- Select your Tab Bar
- Set a Runtime Attibute called tintColor for the desired color of the Selected Icon on the tab bar
- Set a Runtime Attibute called unselectedItemTintColor for the desired color of the Unselected Icon on the tab bar
Edit: Working with Xcode 8/10, for iOS 10/12 and above.
Add Runtime Color attribute named "tintColor" from StoryBoard. This is working(for Xcode 8 and above).
if you want unselected color.. you can add unselectedItemTintColor
too.