How to Set the Navigation Bar Colour in an iOS 8 Launch Screen File? - ios

I'm using a storyboard for my Launch Screen File. It's a very basic setup:
I want to set an opaque colour for the navigation bar...
I can do something like the following in the AppDelegate:
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
But that doesn't apply to the launch screen file.
How do I set the nav bar colour / barTintColor in Interface Builder?

Bar tint is settable for a navigation bar in the Inspector as shown here.
Just checked it with a HOT PINK nav bar in my current project's LaunchScreen.xib and it works fine.

#alexcurylo confirmed that the barTintColor can be set in IB. Part of the problem here was that I couldn't figure out how to select the NavigationBar (I'm not a regular user of Interface Builder)...
Just in case it helps someone else, I was able to select the Navigation Bar, as a child of the Navigation Controller, using the Document Outline pane (I'd failed to do so by left/right clicking on the visual representation...):
Once selected, as #alexcurylo pointed out, it was simply a setting in the Attributes Inspector.

Related

How to change color or navigation bar in launchscreen.storyboard?

So I am trying to use launchscreen.storyboard for my launch screen and I embedded in a navigation bar and a tab bar.
Now my app's navigation bar color and tab bar color is not the default color.
Is there anyway for me to change the launch screen's navigation and tab colors? ( there is no way to add in programmatically since luanchscreen.storyboard is not supposed to have class, right?)
or do I have to use images instead?
Step-1
select your navigationController -> click navigation bar --> change barTintColor
for E.g

Set navigation bottom bar color programatically

Is there away i can set the colour of may navigationController bottom bar colour. Similar to setting top bar in the app delegate with
[[UINavigationBar appearance]setBackgroundColor:color];
can bottomBarColor or something be used?
thanks
The problem is you mistakenly believe that the bar you see at the bottom is a real bar instance/object.
It is not, it is just a simulation of a future situation.
With bar metrics feature in Interface Builder, you can simulate a situation when you view controller will be a part of larger view hierarchy which will contain a bar at a bottom. You can simulate this in design time, and this way you can adjust your AutoLayout constraints, or frames, as if the bar was there so this way the constraints/ frames will behave correctly when it really happens.
If you want a bar with orange colour, you need to have a real bar instance added to some view controller, and change its appearance. But I repeat, it needs to be a real bar instance, not a bar metrics simulation.
Btw, it is AFAIK not possible to put a navigation bar to the bottom, for that you need to use UIToolbar class.
If you want to set the toolbar color globally do this in your AppDelegates didFinishLanchingWithOptions method:
[[UIToolbar appearance] setBarTintColor:[UIColor blackColor]];
Of course your selected color doesn't have to be black.

Navigation Bar not showing in Storyboard

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.

Move navigation bar in navigation view controller in ios7

I want add 20 points margin to my navigation bar. I need it because I want another background color under status bar as youtube did:
I found
iOS Developer library says: Status bar background appearance provided by the window background, if using UIBarPositionTop.
I found solution for toolbar, but I can't move my navigation bar inside navigation view controller. I just set UIBarPositionTop for my navigation bar, but it changes nothing.
-(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
NSLog(#"position method called");
return UIBarPositionTop;
}
I still see the gray background of status bar instead of white.
Is it possible to do it with a navigation bar or should I use a view with a toolbar?
(XCode 6, development target 7.0+, sdk 8.0, autolayout)
UPDATE: ANOTHER WAY TO RESOLVE PROBLEM
I read this question
and understood, that there is no need to add margin. I added view with background color I need over my navigation bar controller and it resolved my problem.
When you are adding your UIView to the UIWindow, you should change the UIViews size to not underlap the title bar. How to do this is well documented in this post:
Offset on UIWindow addSubview
I hope i understood correctly, look in size inspector, ios 6/7 deltas.
Check this link for an explanation:
Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?

Frame shifted up / empty space between view frame and tab bar with tab bar translucent set to "NO"

Here's my scenario:
I have a UITabBar that is using all the default settings and my app's tab bar translucency boolean is set to YES.
I wanted to change the colors of my tab bar, so I set the (iOS 7) tab bar's barTintColor to [UIColor whiteColor].
However, when I saw the app, this tab bar wasn't as white as it should be. After some time looking through the code, the culprit was the translucency of the tab bar. After setting it to "NO", my tab bar was definitely white. However, when I pushed to my next view controller, there was a black space between my view frame in any view controller and the tab bar. setting the tab bar's translucency to YES would get rid of this problem.
I'm not sure what code I can post since I don't do anything special in viewWillAppear or viewDidLoad in my viewcontrollers (other than setting some custom properties for my feature-set)
Any suggestions? Thanks.
edit: I also tried setting a white image in place of the tab bar's background and it did the same thing even though the translucency was set to "YES" this time.

Resources