1
votes

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:

enter image description here

Update

enter image description here

3
Updated the questoinHorray
Black and white, niceBen Affleck

3 Answers

2
votes

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:

  1. 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.

enter image description here

  1. 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.

enter image description here

  1. 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.

enter image description here

  1. See the output in Simulator.

enter image description here

1
votes

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.

enter image description here

0
votes

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.