Black smudge under navigation controller when transitioning - ios

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.

Related

How to remove white space on top of my navigation bar? (swift)

I made an apps with only using XIB (without storyboard). so to navigate I'm using this code to push some of the views:
let vc = SecondViewController()
self.navigationController?.pushViewController(vc, animated: true)
I already make the first vc as rootvc, so it automatically created navigation bar for me.
the problem is the navigation bar generated not at top of the screen and leaving some white space gap. So here is the image when I'm using large title
and here is the normal one
I have tried to run it without safe area layout as well.
what happened is the navbar stayed there but the view goes up (through behind navbar).
navigationController.isNavigationBarHidden = true
Try adding this line to your code for hide default navigation bar.
I've experienced this kind of problem, too.
There are many ways to remove white space.
I want to help you this way.
Add UIView above navigation Bar.
and then, Fix UIView Top constraint.
and change UIView Color.
this is result.
Again, there are many ways...
Use this in your view controller's class:
navigationController?.setNavigationBarHidden(true, animated: animated)
you can change your status bar colour by using. i don’t remember the code but from here you can also can also change your colour in two Default styles
//and use this to hide and show your navigation bar
navigationController.isNavigationBarHidden = true

How can I ensure iOS 13 modal view controllers present the right status bar colour?

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.

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.

UINavigationBar is not showing despite being embedded in NavigationController

I have my ViewControllers embedded in a Navigation Controller, however when I run the app the navigation bar doesn't appear, instead appears as follows:
This is however how my VC in the storyboard looks:
Does anybody have an idea on why might this be happening?
Kind regards - thanks in advance!
Please check if your navigation bar is not hidden, you can do it by isNavigationBarHidden on UINavigationController instance. You can set this value either in storyboard or in code by calling setNavigationBarHidden(_ hidden: Bool, animated: Bool).
Try and Drag Navigation Item to the navigation bar from the storyboard. It worked for me. If not, try setting constraints for the navigation bar. I know it sounds random, but that's how I solved this issue most of the times.

How to completely remove back button from navigation bar?

For some reason I'm adding left and right buttons to the navigation bar as its subview instead of using navigation item. When pushing a view controller, I'm setting its navigationItem.hidesBackButton to YES so that the ugly looking blue 'back' button will not show up. The problem I'm facing is that, after tapping my own back button, while the currently showing view controller being popped --- I mean during the animation of the 'pop', I can see a '...' in the navigation bar moving right along with the popped view controller. And, I DON'T want that '...' to appear for even 0.0000000001 second. What may I do now? Any hint would be appreciated.
Note:Problem solved with just comment. But posting this as answer so that It will help someone else having same issue.
I too had same problem with navigationBarButtonItem while adding custom barButtonItem to navigationBar in storyboard. If you are also using storyboard then just set navigationBar tint color as clear color in navigationController. By setting clear color, that weird default navigation back button will not appear anymore.

Resources