In iPhone SDK 4.2.3, use default Split View template to cook-up a dummy application.
In landscape mode, the master view uses default navigation bar style. In portrait mode, the master view uses black navigation bar style inside the popover. How can i change the bar style/tint color to make it consistent for both views?
I've tried to do this in split view delegate method, but it doesn't work.
pc.contentViewController.navigationController.navigationBar.barStyle = UIBarStyleDefault;
pc.contentViewController.navigationController.navigationBar.tintColor = [UIColor redColor];
I've also tried to explicitly set the navigation bar style in the master view controller class, but that doesn't seem to have any impact as well.
After playing around, i can safely say that it's not possible.
Related
With the new iOS 13 view controller changes, view controllers are being presented that don't cover the whole screen. They instead leave a black space at the top. However, the system status bar is not changing colour automatically. When I present a modal view controller, the status bar is staying with now-invisible black text (and a green battery which looks super weird in the middle of nowhere).
How do I make the bar behave in the same way as within Apple's apps, where the bar animates to different colour when a modal popup appears?
I've tried setting modalPresentationCapturesStatusBarAppearance to true on my modal controllers, to no luck.
The bar in my presenting view controller is a UINavigationBar, and is not part of a navigation controller. The presenting VC is its delegate, and I've overridden position(for bar: UIBarPositioning) to return .topAttached.
I've tried presenting the modal with .modalPresentationStyle = .formSheet and without setting .modalPresentationStyle at all. Neither worked.
Broken:
The presenting VC:
Expected Behaviour:
Two things:
The modal view controllers need to have VC.modalPresentationCapturesStatusBarAppearance = false. This is the default but if, like me, you set it to something else, make sure it's false!
You need to ensure that View controller-based status bar appearance in your info.plist is set to YES. I'd messed around with it in an attempt to make my status bar the right colour but having it set to NO was a problem.
Under iOS 13, if you setup a scrollable root view controller (such as a UITableViewController) in a navigation controller and then put that navigation controller in the detail pane of a UISplitViewController, then the nav bar's background isn't visible when the scrollable content is at the top.
You can see this by creating a new iOS project based on the Master/Detail template. Then modify the storyboard to use a UITableViewController inside the detail pane's nav controller. Put the device/simulator in Light Appearance mode (it shows the problem better than Dark mode). Run the app and notice the nav bar area is the same color as the table view background. Now scroll the table view up and the nav bar color changes to the standard light gray. Let the table view return to the top and the nav bar color disappears again.
I've only seen this in the detail pane of a split view controller.
How do you turn off this "feature" so that the nav bar looks normal just like every other nav bar used anywhere else other than the detail pane of a split view controller?
There are no relevant API changes for UISplitViewController or UISplitViewControllerDelegate. There's nothing in UINavigationController either.
After some digging I found one workaround but I'd love to find a way to avoid having to do this.
The UINavigationBar class now has some new properties for setting its appearance. Oddly, none of these are mentioned under the "Customizing the Appearance of a Navigation Bar" in the documentation for UINavigationBar.
There are three new properties in iOS 13:
standardAppearance
compactAppearance
scrollEdgeAppearance
All three are of type UINavigationBarAppearance.
Only the first one is set by default.
Even though scrollEdgeAppearance is nil, the detail pane of a split controller acts as if this has been set with the backgroundColor set to the clear color.
So the workaround is to add the following line to the viewDidLoad method of the navigation controller's root view controller:
navigationController?.navigationBar.scrollEdgeAppearance = navigationController?.navigationBar.standardAppearance
Why is this needed only in this one case? Is there a more correct solution other than adding this code?
I noticed that none of Apple's apps (Mail, Notes, and Files at least) seem to use this "feature".
The workaround you found is the 'official' way to disable this behavior, as explained in a thread on Twitter by David Duncan who is on the iOS System Experience team at Apple.
to control what happens when the UINavigationBar is completely
unfurled, you want to set the scrollEdgeAppearance. By setting
standardAppearance and scrollEdgeAppearance to the same values, you
will get a bar that doesn't change.
An Apple app that does not disable this behavior is the Settings app.
I've added the Google Places Autocomplete UI control in full-screen mode in my iOS application. Is there any way i can change the navigation bar's background color/tint color in this control?
I have also tried adding a new view controller in my application in an attempt to have better control on the styling. In this new view controller I have my navigation bar with the styles i want, and then added a UISearchController positioned at the top of the view (below the navigation bar). I linked this search controller with a results controller as described in the API docs here:
https://developers.google.com/places/ios-api/autocomplete#add_a_results_controller
However, as soon as i start typing something in the search bar, the results view hides the navigation bar.
I've also added the below code (again as described in the API docs), but it doesn't help either:
self.navigationController.navigationBar.translucent = NO;
_searchController.hidesNavigationBarDuringPresentation = NO;
// This makes the view area include the nav bar even though it is opaque.
// Adjust the view placement down.
self.extendedLayoutIncludesOpaqueBars = YES;
self.edgesForExtendedLayout = UIRectEdgeTop;
Any help will be greatly appreciated!
UPDATE: I think the Autocomplete control only works properly when used in a navigation controller based app. I didn't have one. Now that I've added the navigation controller, the global styles for navigation bar and status bar which i had already defined in app delegate seem to affect the autocomplete modal as expected. The other issue where the navigation bar would get hidden completely as soon as i typed anything in the search box seems to have been fixed as well with the inclusion of navigation controller.
With the latest release of the Autocomplete control (1.11.1, run pod update in your project to make sure you have the latest version) you can tint the navigation bar in a GMSAutocompleteViewController using the appearance proxy, for example:
[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];
This should work whether or not you're using navigation controllers elsewhere in your app.
I am using the theme concept to change UI appearance in my app.I am using multiple themes.I want to change the color of navigation bar of each view controller but except RegisterViewController.So how can i do this?
I have tried following code
[[UINavigationBar appearance]setTintColor:[UIColor redColor]];
[[UINavigationBar appearanceWhenContainedIn:[RegisterViewController class] ,nil]setTintColor:[UIColor blueColor]];
You have the right idea, but the problem is that the navigation bar is not contained in RegisterViewController. It is contained in a UINavigationController.
In other words, if you have one navigation controller and many view controller children, and you want the navigation bar tint to be different for some of those children and not others, you can't do that using the appearance proxy, because in every case it is the same navigation controller and the same navigation bar. There is no distinction to draw.
So you'll have to do it some other way. For example, set up the navigation controller's delegate to change the navigation bar's tint depending on what view controller is coming to the front.
I have 3 views connected together via a navigation controller. The middle view (#2) has special styling in that the navigation bar and toolbar are completely white to blend in with the white background.
When swiping to/from view 2 the navigation and toolbar transition is animated (as is the default) to slowly fade in the buttons and styling of the view being pushed/popped i.e. the navigation bar and toolbar remain visible during the transition.
This ends up not looking to great because of the white navigation bar and toolbar of view 2.
What I would like to achieve instead is to have each view pushed/popped in entirety i.e. including its navigation bar and toolbar. In other words, instead of the navigation bar and toolbar to persist during the transition, I would like them to slide in/out with the view they are part of.
I have attached screenshots of the 2 variants.
Would it be best to scrap the navigation controller and set up each view with its own navigation bar and toolbar? Or can this be achieved easily for my current setup.
It would be great if someone could point me in the right direction.
This is from the Apple Remote app showing the effect I would like to create.
This is from the Apple Mail app showing the default transition effect.
Use custom transitions between view controllers will give you a better effect than animating UIView's, though you can add physics behaviors to UIView objects to make it more interesting.
Apple uses interactive custom transitions (just look that up) for its own apps. Here is a good article about that too:
http://www.doubleencore.com/2013/09/ios-7-custom-transitions/
Create your view with the desired screen with navigation bar & tollbar.
On the action bring the view 2 or remove with the animation your want using view animation.
[UIView animateWithDuration:0.2
animations:^{set your fram(0,0,320,480/568) or (320,0,320,480/568)}
completion:^(BOOL finished){
}];
You can add the view to keywindow.
Hope this will help you.
Why don't you simply use the hidesBottomBarWhenPushed property over the destination view controller?
// hide the bottom tabbar when we push this view controller
destinationViewController.hidesBottomBarWhenPushed = YES;