How to enable scrollEdgeAppearance manually? - uinavigationbar

I have a controller without large title, I noticed that appearance in detail pane of UISplitViewController will enable scrollEdgeAppearance automantically.
So how can I use scrollEdgeAppearance in other controller?

Related

New UINavigationBar appearance in detail pane of UISplitViewController in iOS 13

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.

Black smudge under navigation controller when transitioning

When I'm tabbing between pages attached to a navigation controller, sometimes there is a black mark under the navigation bar..
any ideas how to remove this?
they're just blank pages.
let vc = self.storyboard!.instantiateViewController(withIdentifier: page)
self.show(vc, sender: self)
i have tried setting background to white in navigation controller class like some threads recommend which didn't do anything.
The "smudge" happens when you transition between a view controller whose edgesForExtendedLayout include .top and one that does not. To avoid it, make sure all your view controllers have the same edgesForExtendedLayout and the same extendedLayoutIncludesOpaqueBars settings.
for me, It happens when I use ToolBar from libraries. fix by using ToolBar from the navigation controller itself by toggle "Shows Toolbar" in Navigation Controller's Attribute Inspector
I had this issue with my app as well, except I had a black smudge under the Navigation Bar and a Toolbar. I eventually discovered that the problem was because of the isTranslucent property of the UIToolbar I had in multiple scenes.
Once I set this property to false, the black smudge under both the Navigation Bar and the Toolbar went away (why disabling translucency on the Toolbar fixes the Navigation Bar as well, I don't know). I had tried disabling isTranslucent on the UINavigationBar, but that only fixed the smudge on top. Luckily, in my case, nothing will ever be under the Toolbar, so disabling translucency is not a problem. If translucency under the Toolbar is required, this solution may not work for you.

Apple News app scrolling buttons in UINavigationBar

How to implement such a navigation bar? I am aware of the title view but not aware of any subtitle view.
One way I can think of is setting UINavigationBar shadow image to nil and place collection view below the navigation bar. But that won't give me translucency of Navigation bar.
Is there a native way (which may have been introduced in iOS9) of doing so?
I think you'll have to make custom view and will have to use it as navigation bar. Hide the default navigation bar and use your custom view.
I wanted to make the nav.bar as shown in picture with the functionality like tab bar and i've made custom view for that purpose.
You can use a library like PageMenu or PagingMenuController to do this easily.

How to link customized navigation bar to navigation controller?

I created a normal view controller with a customized navigation bar. Later I changed my mind to embed the view controller into a navigation controller. And I noticed that embedding the view controller into a navigation controller will create another navigation bar!
As the image show:
I am wondering if there is a way to replace the navigation bar created by navigation controller with my own customized bar?
Or, if it's not possible, is there a way to configure the new navigation bar? Because for some reason it's not shown in my interface builder.
You have 2 solutions
Hide the system navigationbar using below code so it was display your custom navigation.
self.navController.navigationBarHidden = YES;
Customize the system navigation bar with its background color, back button and title text color. For this you can refer a below links which provide you detail of its
http://www.appcoda.com/customize-navigation-status-bar-ios-7/
You can change the color and buttons of the UINavigationBar provided by the system and make it look like yours.

Hide Navigation Bar in Interface Builder w/ Storyboards

I have a pretty basic storyboard based app, with a UINavigationController, a main view and a secondary view, both of which are in the navigation hierarchy. I’m currently hiding the navigation bar on the main view by using setNavigationBarHidden: as appropriate in viewWillAppear and viewWillDisappear. It seems like there should be a way to do this in Interface Builder, rather than in code. Essentially I’d like the options available in the Simulated Metrics options, but not simulated. Does that exist?
In the scene for the UINavigationController itself, I suppose you could check the hidden button for the nav bar in the Attributes inspector, but that would make the nav bar hidden for all the view controllers in the navigation stack. But that's not what you want.
To hide the nav bar for an individual view controller using IB, you would need to use a stand alone nav bar for each view controller (e.g., drap and drop a Navigation Bar from the object library in IB). To use a stand alone nav bar in a navigation stack would be more work than programmatically hiding the nav bar.
Just uncheck the Attribute Inspector > Shows Navigation Bar in Attribute Inspector

Resources