2

I've found a post on how to change the tint color of the tab bar button, but it assumes you are using a tab bar controller. I tried any way and did not make a difference. I am using a regular UIView and dragged a Tab Bar control on there. How do I change the button tint color in this scenario? The storyboard and code suggestions are not making a change. I tried to add these into my viewDidLoad ever, but neither had an effect:

self.view.tintColor = UIColor.orangeColor()
self.tabBarController?.tabBar.tintColor = UIColor.orangeColor()

I was able to change the nav bar buttons tints via the storyboard no problem, but the tab bar isn't having any effect. I am trying to match the changes I did to the nav bar:

enter image description here

Community
  • 1
  • 1
TruMan1
  • 33,665
  • 59
  • 184
  • 335

1 Answers1

0

If you are using a Tab Bar Controller, this will work for the tab bar background color:

tabBarController?.tabBar.barTintColor = UIColor.whiteColor()

And this for the color of the items within the tab bar:

tabBarController?.tabBar.tintColor = UIColor.blackColor()

If you are not using a Tab Bar Controller, and you just dragged a tab bar into your view controller: Control drag from the tab bar in your storyboard to your view controller's swift file to create a new referencing outlet. It should something like this if you're unfamiliar:

@IBOutlet weak var myTabBar: UITabBar!

Then use that same lines of code above just replacing a few things:

myTabBar.barTintColor = UIColor.whiteColor()
myTabBar.tintColor = UIColor.blackColor()
user3353890
  • 1,844
  • 1
  • 16
  • 31
  • This only effects the selected menu item, but what about setting colors for the unselected items? – TruMan1 Apr 29 '15 at 11:22
  • For unselected items take a look at this post. You change the color of the tab bar items as opposed to the bar itself: http://stackoverflow.com/questions/25052729/default-tab-bar-item-colors-using-swift-xcode-6 – user3353890 Apr 29 '15 at 19:38