Reputation: 139
I created an app in iOS 5 using Storyboard to lay out my screens. I have a tab bar controller and the bottom tab bar with 4 icons. I want to change the color from black to a graduated green. I can make a .png file, but can't figure out how to replace the black fill with my green fill.
I've seen some posts on code to do this but seems iOS 5 is different than if the device is running iOS4 and I can't figure out where to put the code.
Thx
Upvotes: 4
Views: 6748
Reputation: 59
Here is what worked for me:
In AppDelegate.m I put the following code after // Override point for customization after application launch.
[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
Hope this helps :)
Upvotes: 4
Reputation: 2827
You can either set the color on the storyboard by selecting the root: Tab Bar View Controller, select the tab bar, and adjust the Background (or tint) color in the attributes inspector, or you can adjust the code with the barTintColor:
// Adjust the Color of the Tab Bar itself
self.tabBar.barTintColor = [UIColor redColor];
// Adjust the Color of the selected Icon in the Tab Bar
self.tabBar.tintColor = [Single single].singleThemeColorTint;
If you need to adjust the ALPHA too, I would use:
UIColor *charcoal = [UIColor colorWithRed:66/255.0
green:79/255.0
blue:91/255.0
alpha:1];
// For Tab Bar
self.tabBar.barTintColor = charcoal;
// For selected Item Highlight
self.tabBar.tintColor = charcoal;
I created a View Controller File for the Tab Bar Story Board, and ran this code in ViewDidLoad{ }
Upvotes: 3
Reputation: 4091
If you have created your application using storyboard API, then you cannot support iOS4, they rely on new runtime classes which are not available there.
Upvotes: 0
Reputation: 1729
Here is the wonderful blog post of Ray WenderLich.
User Interface Customization in iOS5
http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5
Upvotes: 0