I'm trying to design my app's interface in IB using a storyboard and have a UINavigationController connected to a UITableViewController. In the attributes inspector, I set the navigation controller's "Bottom Bar" property to "Toolbar". However, when I select the Toolbar and try to change its tint, I am unable to - no matter what color I select, the tint remains at Default. What's weird is, I have the navigation controller's "Top Bar" property set to "Navigation Bar", and I'm able to change it's tint just fine. Does anyone have any idea as to why this is happening?
Thanks in advance.
I remember reading somewhere that the storyboard is only to help you visualize the layout of the toolbar.
You can change the color of the toolbar in your root view controller's view did load method using:
self.navigationController.toolbar.tintColor = [UIColor redColor];
Related
Hi I am developing small Iphone application in which I am giving colour for my navigation bar like this
[self.navigationController.navigationBar setTranslucent:NO];
[self.navigationController.navigationBar setBarTintColor:[UIColor redColor]];
But because of this my status bar also become of red colour. I want to change it to white. I tried in followings way but those are not working for me.
in info.plist file I set View controller-based status bar appearance = "NO"
then in application:didFinishLaunchingWithOptions: set [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Then in UIViewcontroller
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
But above methods are not working for me. My navigation bar and status bar of same colour. I want to make status bar colour to white. My application is very simple having one UIView controller with one navigation controller. Am I doing some thing wrong? Need Help. Thank you .
UIStatusBarStyleLightContent tells the status bar to display light colored text, but it is still transparent. And because the navigation controller reports the position of its navigation bar to be UIBarPositionTopAttached, you see the effect of the navigation bar's color stretching beneath the status bar.
Here are two ideas how to achieve what you are looking for:
Subclass the navigation controller, implement - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar and return UIBarPositionTop. This make the navigation bar not stretch beneath the status bar, and instead the superview of the navigation bar (which is usually white), will show.
Or, better, subclass the navigation controller, add a subview of 20pt height above the navigation bar, and in viewDidLayoutSubviews, position and resize the subview correctly to orientation. Now you can give any color you'd like to this view, and it will be the color of the status bar.
Edit: Based on the comments, the positionForBar: approach may not work.
I have an issue, when I set the translucent box off on a TabBar, there is something blocking some of my view.
It looks like it's a sort of extra tab bar or I don't even know. I'm using storyboard.
Please see the images attached:
With Translucent (OFF - NO):
With Translucent (ON or YES):
Does anybody know why it looks like this?
Thanks
PS: Which tabBar do you guys like? Black or this one:
This happens in iOS7 when you set tabBar.translucent to NO. iOS is trying to be smart and say "hey the tabbar is not translucent so we better push everything up on top of it". Fix it by setting the extendedLayoutIncludesOpaqueBars property of the view controller inside the navigation controller which is inside the tabbar controller to YES.
Example (not actually ran):
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.tabBar.barStyle = UIBarStyleBlack;
tabBarController.tabBar.translucent = NO;
UIViewController *viewController = [[UIViewController alloc] init];
viewController.extendedLayoutIncludesOpaqueBars = YES; // <-- This is important!!!!!!
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: viewController];
tabBarController.viewControllers = #[navigationController];
Source: https://web.archive.org/web/20160405135605/https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/AppearanceCustomization.html
And BTW, I like the non-translucent tabbar the best.
Edit
As Andy mentioned below, this flag does not have to be set in code. You can set it in IB if that's what you use.
As mentioned here you have to set barTintColor to something you want to change the color.
These settings automatically apply when you set any style for barStyle or any custom color for barTintColor. If you prefer, you can make the tab bar opaque by setting the translucent property to NO programmatically. In this case, the bar draws an opaque background using black if the tab bar has UIBarStyleBlack style, white if the tab bar has UIBarStyleDefault, or the tab bar’s barTintColor if a custom value is defined.
Something that I used for my project
self.tabBarController.tabBar.barTintColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0];
self.tabBarController.tabBar.translucent = NO;
I have acontroller with TableView and both translucent NavigationBar and translucent TabBar. In this situation using viewController.extendedLayoutIncludesOpaqueBars = YES; causes a problem of both bars overlaping my table view. It can be managed by setting viewController.edgesForExtendedLayout = UIRectEdgeBottom; which results in TableView hiding only behind Tab Bar.
It looks like you've set up the view controller's view so that its bottom is at the same position as the top of the tab bar, when it should be at the bottom of the screen. If you do that, then your content will appear correctly (content visible through the tab bar or not) whether the tab bar is set to translucent or not.
For those who actually want a translucent Tabbar and a table view (or collection view for me) that can be seen behind, here is my solution for ios 7/8:
If you are using constraints, you should add one on the bottom of the table view to the "Bottom Layout Guide" so your tableview stops before the Tabbar. This is an example with Storyboard, but it can be done in code as well.
Then you just need to make sure you can still see the table view behind the Tabbar by settings the "clipsToBounds" property to NO.
self.mytableview.clipsToBounds = NO;
This is my solution, hope it helps.
I don't think the currently accepted answer is correct. You don't need to extend the layout under opaque bars to solve the issue.
There is no code provided in the OP, but it is likely that the bottom of the view containing the items is constrained to the bottom of its superview, which would have taken the items underneath the translucent tab bar. To prevent this, a manual inset could have been set from the bottom. In short, the superview extends underneath the translucent bar and so did its subviews.
As soon as the tab bar was made opaque, the root view (or the superview) only extended until the top of the tab bar.
The 'more' correct fix would be to just remove the manual inset of content, not extending the view under opaque bars.
I'm trying to change a UINavigationController navigation bar to my custom navigation bar (subclass of UINavigationBar) with IB.
So I have a xib file with a UINavigationController, but when I stand on the navigation bar and go to the inspector to change it's class, It shows me a UINavigationItem class not UINavigationBar, and I can't choose my custom navigation bar.
What am I doing wrong?
To answer my own question, I found the solution in this post
Only after I tapped on the "Show Document Outline" button (the rounded arrow at the left bottom), I could find the navigationBar under the navigation controller, and change his class.
I have a couple of views in my iPhone app.
each view shows a "top bar" in blue, I haven't added a "Navigation Bar", simply edited what's on the inspector "View Controller" section and gave it a title. (this section: http://img69.imageshack.us/i/schermata20101001a22014.png/)
Is it possible to change the color of this bar that'a automatically added on top of other View Items? or even to hide it? both In Interface Builder or in Code,
thanks.
I'm not sure how to change the one added automatically, I assume that you'll have to make your own to change things such as the color, which you can do easily with the tint option in the attributes panel.
It's the navigation bar from the UINavigationController. You can do stuff like [self.navigationController setNavigationBarHidden:YES animated:YES] and self.navigationController.navigationBar.tintColor = [UIColor magentaColor].
You should not set the navigationBar.hidden/alpha directly, since those are handled by the UINavigationController. Additionally, UINavigationController may not re-layout your views appropriately.
I think I must be going nuts here. I have a UINavigationController and in every view that I have pushed I have selected Black Navigation Bars in IB, but they all turn up as translucent ones.
What have I done wrong?
Thanks
Is the translucent property on the UINavigationBar set properly?
Check your code to see if translucent is set somewhere or add this to your VC to print out the value:
NSLog(#"navBar.translucent = %d",
(int)navController.navigationBar.translucent);
And check the Navigation Controller in IB, the Navigation Bar section should have a Style of Black Opaque (not Black Translucent), and an Alpha of 1.00.
Nav Bar in IB http://morrisphotoart.com/tmp/Screen%20shot%202010-04-20%20at%2005.43.26.png
Are you sure you are not re-declaring the color of the bar in code somewhere?