Change color of tab bar - ios

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

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 :)

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{ }

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

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.

Related

View Controller Top Bar not editing

In my view controller, I have changed the color of the top bar in the simulated metrics, I have changed it to be 'Translucent Black navigation bar', but when I start up my app in the simulator my top bar is still white.
BarSimulated metrics only affect how the NavigationBar's overview is displayed in the Interface Builder. The actual NavigationBar is either part of your viewController's navigationController or a view you added manually.
With UINavigationcontroller:
self.navigationcontroller.navigation.translucent = false
With custom UINavigationBar:
self.myNavigationBar.translucent = false
Try setting the NavigationBar tint colour as following screenshot.
Simulated metrics exist just that you can see what it will look like on launch. It doesn't really affect your app.
If you want to change your navigationBar's color, you must do it programmatically:
SWIFT
// in ViewController
navigationController.navigationBar.barTintColor = UIColor.greenColor()
OBJ C
// in ViewController
self.navigationBar.barTintColor = [UIColor greenColor];

Is there a way to change the back button color when using the navigation controller in Xcode [duplicate]

I'm having problems trying to figure out how to change the color of the buttons on the navigation controller.
Previously I had used the following:
[[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:226/255.0 green:66/255.0 blue:66/255.0 alpha:0.0]];
and this worked, but I added a new view with a toolbar, and the tool bar button images will not show. If I remove the global coloring, the tool bar items show just fine.
I've tried setting the tint color on both the leftBarButtonItem and the backBarButtonItem in the viewDidLoad method of the view, but both of those properties appear to be null.
I don't want to change the color of the entire navigation bar, just the buttons. Is there a way to do this?
Yeah, I'll just post this as an answer. Your alpha is set to 0. So you're basically saying the same thing as [UIColor clearColor].
Not sure how that ever worked to give you a tint color on your bar button items.
In swift, it can be accomplished by the following command:
if let navController = self.navigationController
{
navController.navigationBar.tintColor = UIColor.whiteColor()
}

is it possible to apply two navigation colors for two view controller in iOS

i have situation where i need to have blue color as navigation bar color for first view and for second view i should have as green color .when i tried to apply it using below code.
in viewdidload for 1st view:
self.navigationController.navigationBar.barTintColor = [UIColor bluecolor];
in view did load in second view:
self.navigationController.navigationBar.barTintColor = [UIColor greenColor];
the color remains same as in first view i was unable to change it,and how to remove glassy effect on navigation bar.
Select your navigation controller in your view hierarchy(in Storyboard), select the navigation bar and from there you can set the color in the attributes inspector.

How can I set the correct Nav Bar tint color?

I am creating a title view in my navigation bar. I designed my title view with background view color R:255 G:182 B:22 (on photoshop). In my storyboard, I've set the navigation bar tint color with the same RGB code, default style and translucent checked.
I put my image on my navigation title using:
UIImage *titleImage = [UIImage imageNamed:#"Icon-Small-40.png"];
self.navigationItem.titleView = [[UIImageView alloc]initWithImage:titleImage];
When I run the app, you can clearly see a square icon in the title view. The title view has a slightly darker background. I want to make the background the same color. I get the feeling that it has something to do with some storyboard setting but I can't find the issue.
the view has a tintColor property, so
self.navigationItem.titleView.tintColor = ...
Below answer for your navigation bar tint color
self.navigationController.navigationBar.tintColor = [UIColor greenColor];
Trying to make colours match up like this can be maddening. Colour space problems aside, the actual colour of the navigation bar isn’t guaranteed by the API to be the same as its barTintColor. You might find it easier to give the title image a transparent background.

iOS - How to change color of icons in tab bar moreViewController

I want to change color of icons (and probably badge) in moreNavigationController from gray to something else.
I've read and successfully changed color of background and text. I did this by "replacing" data source of moreViewController (described e.g. here Customizing the More menu on a Tab bar ). But updating icons (also textLabel value) here makes no effect. Is it possible to change this gray color to white (or anything else)? Or I have to implement my own tabBarController? (any good tutorials?)
PS. I know how to change icons on tab bar itself, the question is how to do this in moreViewController?
Thanks!
Piotr
In case it is still relevant to anyone.
You can change icon colors displayed in a tableView of moreViewController:
self.tabBarController?.moreNavigationController.topViewController?.view.tintColor = UIColor.redColor()
Changing a title is like so:
self.tabBarController?.moreNavigationController.navigationBar.topItem?.title = "MyString"
Changing Edit button:
self.tabBarController?.moreNavigationController.navigationBar.tintColor = UIColor.redColor()
You can do this using the appearance proxy, new in iOS 5. In your app delegate's didFinishLaunching method:
[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
In iOS 7 use:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
See the UITabBar class reference for more details.
Ok, from long research on the web and answers in this thread, it seems that it is not possible on iOS7 to change color of the icons (gray color) displayed in moreViewController of UITabBarController. The best solution for customizable tab bar is to implement it (or use some library).
Thanks!
You can change the color, just subclass the tab bar controller and in it's view did load add the below code
override func viewDidLoad() {
super.viewDidLoad()
var view = self.moreNavigationController.topViewController.view as UITableView
view.tintColor = Utilities.mainColor()
view.separatorStyle = .None
}
For more you can see my question here : Change tint color of tabbar edit view controller

Resources