On iOS 7, setting the UISearchBar to be translucent isn't making the search bar translucent. Is there anything I'm not understanding it? I'm adding it to a UIViewController that is part of a UINavigationController. There's a UITableView aligning to the Top Layout Guide. The navigation bar is fine and has translucency, but the search bar is a solid color for some reason.
See the new .searchBarStyle property on UISearchBar. I suspect UISearchBarStyleMinimal is what you're after.
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 a problem with a UISearchViewController (using a storyboard layout).
My main view controller has a navigation bar at the top, beneath which I have positioned the UISearchBar. A MKMapView extends below the search bar and navigation bar.
When the SearchViewController is active, the Navigation Bar slides up. I have added an autolayout constraint to stick the uisearchbar to the bottom of the nav bar. However, the search bar doesn't appear to extend beneath the status bar and above the map view. Instead the mapview appears in a 20px gap above.
Any help would be greatly appreciated!
Setting translucent to false on my navigation bar did not fix this. However setting the translucent property of my searchBar worked for me.
I used these UISearchDisplayDelegate methods to change the value depending on whether the searchBar is active or not.
func searchDisplayControllerWillBeginSearch(controller: UISearchDisplayController) {
// self.searchBar is an IBOutlet from storyboard
self.searchBar.translucent = false
}
func searchDisplayControllerWillEndSearch(controller: UISearchDisplayController) {
self.searchBar.translucent = true
}
I think it can be fixed with navigationBar.translucent = NO; It is set to YES by default in iOS 7. Had a lot of trouble with that myself.
Try this in info.plist file to disable the status bar
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 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?
I have the search bar in the top of the table and the hidden navigation bar. Along with UISearchBar I use UISearchDisplayController. UISearchDisplayController has the possibility to bring forward the navigation bar. So, when I tap the cancel button in the search bar, the navigation bar fly's down. How can I dismiss this possibility, so the navigation bar will always be hidden?
Thanks
One solution is to make the search bar the table header view in which case it will scroll with the table, and if you don't want it to appear by default then you can programmatically scroll the table down, non-animated, in viewWillAppear it is first displayed. This may or may not make sense for your UI design, but it is, for example, how Safari basically works.
Finnaly!!!! I've found the solution IPHONE: ABPeoplePickerNavigationController hidden navigation bar