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.
Related
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 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.
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.
I need to put segmented control into navigation bar below the title and other buttons. How do I make this? Everything I found so far says you can't increase the height of navigation bar without hacks. Is it even possible?
https://drive.google.com/file/d/0B2fViGVp6nhhOEdJSU0zeWZiS1U/view?pli=1
Why don't you put both of them separately? On top navigation bar and below that UISegmentControl.
Just make sure background for UISegmentControl should be matched and aligned with UINavigation bar.
Hope that helps.
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?