View Controller Top Bar not editing - ios

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];

Related

NavigationBar barTintColor showing different effect for same color

I am trying to set color to navigation bar for different controllers but same color showing different effect.
Add following line to your viewDidLoad:method of navigationController class,
self.navigationBar.translucent = NO;
Visit navigationBar translucent property.

Navigation Bar color

I'm building an map app and have label with information of my route. I've set programmatically color of the label and navigation bar with the same hex. But while testing the app, I've noticed that they are different a bit. Can anybody tell me, what is wrong?
screenshot
Main color is in Util class; nav bar appearance is set in app didFinishLaunchingWithOptions method; label color is set in viewWillAppear of my map VC
public static let mainColor = UIColor(fromHexCode: "#335E40")
UINavigationBar.appearance().barTintColor = Util.mainColor
infoLabel.backgroundColor = Util.mainColor
Did you turn off the transition?
UINavigationBar.appearance().translucent = false

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()
}

When the UITabbar is Translucent and the UIViewController is not extended behind the tabbar, the uitabbar seems like covering a black view

The tabbar in first view is what I want. Because the second view isn't a scrollview, so I can't extend it to bottom by using self.edgesForExtendedLayout = UIRectEdge.Bottom.
It looks unacceptable.
And I don't want to set Translucent of uitabbar to false, it's not fancy.
I try in another way:
[[UITabBar appearance] setBarTintColor: [UIColor whiteColor]];
It doesn't work. To make it looks more clear, I change the color to red. And the last tabbar also looks like covering some black views.
Consider of the tabbar is translucent, what's the view under the UITabbar view?
This is the final answer of why it doesn't work when changing the tintcolor of bar. Because the view under UITabbar view is black.
Thanks to the Xcode awesome debugging function. We could locate the view under UITabbar view easily.
It's UIWindow. So the solution is to simply change the window's backgroundColor to white.
I would say that adding this code in viewDidLoad of your viewController will solve your issue:
edgesForExtendedLayout = .all
extendedLayoutIncludesOpaqueBars = true
Plus you can keed your tabBar translucent and not set any background color.

Change color of tab bar

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.

Resources