[ios] Change tab bar item selected color in a storyboard

I want to change my tab bar items to be pink when selected instead of the default blue.

How can i accomplish this using the storyboard editor in Xcode 6?

Here are my current setting which are not working, the blue background works but the pink doesnt work:

enter image description here

This question is related to ios xcode xcode6 uitabbar uitabbaritem

The answer is


You can also set selected image bar tint color by key path:

enter image description here

Hope this will help you!! Thanks


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.


XCode 8.2, iOS 10, Swift 3: now there's an unselectedItemTintColor attribute for tabBar:

self.tabBar.unselectedItemTintColor = UIColor(red: 0/255.0, green: 200/255.0, blue: 0/255.0, alpha: 1.0)

On Xcode8 I have changed the ImageTint from the storyboard and it works well.

enter image description here

The result:

enter image description here


Add this code in your app delegate -did_finish_launching_with_options function

UITabBar.appearance().tintColor = UIColor( red: CGFloat(255/255.0), green: CGFloat(99/255.0), blue: CGFloat(95/255.0), alpha: CGFloat(1.0) )

put the RGB of the required color


Somehow we are not able to change the Tab Bar selected item Tint color using storyboard alone, hence I added below code in my ViewDidLoad, hope this helps.

[[UITabBar appearance] setTintColor:[UIColor whiteColor]]; 

This is the solution in Swift 3 that works in iOS 10:

Firstly, you create your own tab bar controller subclass and add it to your tab controller in your storyboard. In the viewDidLoad() method you can then customize the tab bar. It should be stated here that the tintColor attribute of the tabBar represents the color of the selected item not the color of the unselected ones! In order to change the color of the unselected items, I recommend looping through each item and use the original colors of your images, so they are not rendered as grey automatically.

class CustomTabBarVC: UITabBarController
{
    override func viewDidLoad()
    {
        super.viewDidLoad()

        self.tabBar.tintColor = AppColor.normalRed
        self.tabBar.barTintColor = .white
        self.tabBar.isTranslucent = true

        if let items = self.tabBar.items
        {
            for item in items
            {
                if let image = item.image
                {
                    item.image = image.withRenderingMode( .alwaysOriginal )
                }
            }
        }
    }
}

The only downside with this approach is that your item images must already have the desired color you aim for.


This best way is to change Image Tint in storyboard

enter image description here


This elegant solution works great on SWIFT 3.0, SWIFT 4.2 and SWIFT 5.1:

On the Storyboard:

  1. Select your Tab Bar
  2. Set a Runtime Attibute called tintColor for the desired color of the Selected Icon on the tab bar
  3. Set a Runtime Attibute called unselectedItemTintColor for the desired color of the Unselected Icon on the tab bar

enter image description here

Edit: Working with Xcode 8/10, for iOS 10/12 and above.


put this code in the viewDidLoad of the view controller that you want to change the color of

[[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];

You can subclass the UITabBarController, and replace the one with it in the storyboard. In your viewDidLoad implementation of subclass call this:

[self.tabBar setTintColor:[UIColor greenColor]];

You can change colors UITabBarItem by storyboard but if you want to change colors by code it's very easy:

// Use this for change color of selected bar

   [[UITabBar appearance] setTintColor:[UIColor blueColor]];

// This for change unselected bar (iOS 10)

   [[UITabBar appearance] setUnselectedItemTintColor:[UIColor yellowColor]];

// And this line for change color of all tabbar

   [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];

Swift 3 | Xcode 10

If you want to make all tab bar items the same color (selected & unselected)...


Step 1

Make sure your image assets are setup to Render As = Template Image. This allows them to inherit color.

Xcode Assets


Step 2

Use the storyboard editor to change your tab bar settings as follows:

  • Set Tab Bar: Image Tint to the color you want the selected icon to inherit.
  • Set Tab Bar: Bar Tint to the color you want the tab bar to be.
  • Set View: Tint to the color you want to see in the storyboard editor, this doesn't affect the icon color when your app is run.

Xcode Storyboard Editor


Step 3

Steps 1 & 2 will change the color for the selected icon. If you still want to change the color of the unselected items, you need to do it in code. I haven't found a way to do it via the storyboard editor.

Create a custom tab bar controller class...

//  TabBarController.swift

class TabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // make unselected icons white
        self.tabBar.unselectedItemTintColor = UIColor.white
    }
}

... and assign the custom class to your tab bar scene controller.

Xcode Storyboard Editor


If you figure out how to change the unselected icon color via the storyboard editor please let me know. Thanks!


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code

Examples related to xcode6

'Framework not found' in Xcode No suitable records were found verify your bundle identifier is correct unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard Move a view up only when the keyboard covers an input field My prerelease app has been "processing" for over a week in iTunes Connect, what gives? Programmatically navigate to another view controller/scene Changing the Status Bar Color for specific ViewControllers using Swift in iOS8 Change tab bar item selected color in a storyboard How do I change UIView Size? How to get textLabel of selected row in swift?

Examples related to uitabbar

Changing tab bar item image and text color iOS Change tab bar item selected color in a storyboard What size should TabBar images be? Changing Tint / Background color of UITabBar

Examples related to uitabbaritem

Changing tab bar item image and text color iOS Change tab bar item selected color in a storyboard What size should TabBar images be?