I embeded in a navigation controller to a viewController, and a nav bar item is showing (in the outline editor), and I can change the title, but the navigation bar is not showing in the (outline editor) and I therefore cannot change the bar tint color. So I tried adding in a nav bar programmatically, like this:
.h file
#property (strong, nonatomic) UINavigationBar *nav;
.m file
nav = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
self.nav.tintColor = [UIColor blueColor];
[self.view addSubview:nav];
And here is the outcome:
Update
Your last comment in above answer that "I made the color to blue, and it shows it blue in the storyboard" is conflict here.
I guess you are not able to set tint color for navigation bar. Because Storyboard won't show any color tint color for navigation bar, it's only visible at run time (In Simulator).
Even if you change tint color of navigation bar it still shows white color.
Lets have a look:
As "matt" said : You have to change bar tint color of UINavigationController which is starting point of your application. Select navigation controller which is initial root view controller.
Select Navigation Bar from left area below the highlighted Navigation Controller. In Attribute Inspector you can see properties for navigation bar. In this section you can see Bar Tint which shows Default right now.
Change Bar Tint color from properties as your need. Observation here is changes will not be visible in Storyboard, Bar color will remains white in Storyboard color will only visible in Simulator/Device.
See the output in Simulator.
Don't do that. Delete that code. The navigation controller already has a navigation bar; don't add another one.
You're looking in the wrong scene. There's a Navigation Controller scene and a View Controller scene. The navigation bar belongs to the Navigation Controller scene.
I was using the viewController that is flexible for the ipad and iphone. Now in that viewController I inserted a navigation controller for each viewController. (Which surprisingly xcode lets you do that. And at the time I didn't know it was wrong.) So I set the bar tint color at the navigation controller that was not the first one. (It was the second view navigation controller) It therefore had a conflict of which color to take, the color from the first navigation controller, or the current navigation controller.
Related
This view is Present from mainviewcontroller then i set large title on this view then then i change color of navigation bar but color is not change in outside of safe area in navigation bar.
so, how can i change color in whole navigation bar in iPhone X.
Thanks.
In my application i would like to change color of content view not the navigation bar color
I have written like self.window.backgroundColor = [UIColor redColor]; but its changing whole content color including navigation bar color.
You could just make your UINavigationBar to not be translucent. If you are working with Interface Builder then you should go to your UINavigationController, select the UINavigationBar and uncheck the Translucent property. If you are doing this in code you can just call self.navigationBar.isTranslucent = false.
You need to set self.view.backgroundColor on any view controllers you want to adopt your new colour. Setting it on the window causes the navigation bar to change colour because it has transparency and therefore you can see the window background colour through it.
I recommend subclassing UIViewController and setting this in viewDidLayoutSubviews. Then, making all your other view controllers subclass this one. This means you don't have to write the same code for every view controller.
I want my SplitViewController to be embedded in TabBarController. I started with a Single View Application. Then I used storyboard to connect all controllers as shown on this image.
The navigation works fine, but the problem is at the top and bottom bar background colour. I would like to use Translucent Black Navigation Bar and Tab Bar. For some reason, the background colour of Navigation Bar and Tab Bar in master view is grey instead of purple (colour of master view background). In detail view the colour is fine. Problem is clearly seen on this image.
I tried to manually set the colour of NavigationBar but it didn't help.
I want my tab bar to be translucent and blur the content behind it, but when I set its color to clear color it turns black instead. Currently I have my tab bar created programmatically in the app delegate. I made a class function called getTabBarController and configured my tab bar in there, and I call it in app delegate to return the tab bar. At last, I write
let vc = TabBarInitializer.getTabBarController()
self.window!.rootViewController = vc. Am I creating my tab bar incorrectly? How do I make the tab bar be on top of my content so that the translucent effect works?
You have place view or content behind tabbar which you have to show instead of black.
So when tab transparent, view behind the tabbar become visible.
I have a UINavigationItem (not a UINavigationBar) that I would like to make transparent or not opaque. This gets created when I make a relationship segue root view controller from a Navigation Controller to my UIViewController subclass.
I tried to embed it in a UINavigationBar, but couldn't make that work. There do not appear to be any methods for UINavigationItem that would allow me to change the appearance of its background.
Is there any way to accomplish this, either by embedding it inside a view of some sort or by getting a pointer to some object that has this capability?
Here is the storyboard that shows the hierarchy of the view controller. You can see the UINavigationItem as a direct descendant of the view controller. Notice that there is no explicit reference to a UINavigationBar:
Here is an image of the navigation section at the top of my UIViewController when it renders. I'd like to change the light gray to match the dark gray that you can see just below it:
From the docs:
In iOS 5.0 and later, you can customize the appearance of the bar using the methods listed in Customizing the Bar Appearance. You can customize the appearance of all navigation bars using the appearance proxy ([UINavigationBar appearance]), or just of a single bar.
In iOS 7, a navigation bar’s tintColor affects the color of the back indicator image, button titles, and button images. The barTintColor property affects the color of the bar itself. Additionally, navigation bars are translucent by default. Turning the translucency off or on does not affect buttons, since they do not have backgrounds.