Change the color of the tab bar

I created an application in iOS 5 using Storyboard to lay out my screens. I have a tab bar controller and a bottom tab bar with 4 icons. I want to change the color from black to graded green. I can create a .png file, but I cannot figure out how to replace the black fill with my green fill.

I saw some messages in the code to do this, but it looks like iOS 5 is different from whether the iOS4 device is working, and I cannot figure out where to place the code.

thanks

+4
source share
4 answers

Here is what worked for me:

In AppDelegate.m I put the following code after // Replace the point to configure after starting the application.

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

Hope this helps :)

+4
source

You can set the color on the storyboard by selecting the root element: the table control panel, select the tab bar and edit the background color (or hue) in the attribute inspector or you can customize the code using 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 configure ALPHA as well, 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 String Bar and displayed this code in ViewDidLoad {}

+3
source

Here is a wonderful blog post by Ray WenderLich.

User Interface Customization in iOS5

http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5

0
source

If you created the application using the storyboard API, then you cannot support iOS4, they rely on new runtime classes that are not available there.

0
source

All Articles