Reputation: 807
!NOTE: I've seen some other questions reporting about a black bar appearing but that question is not a duplicate (correct me if I am wrong) for me there is something like a black view appearing when I my push segue is executed. Non of the solutions for the problem with the black bar worked for me (difference: There is a black view appearing for me).
I used the standard "show" segue in the storyboard. The following is the code inside viewDidLoad
of my first UIViewController
(this vc performs the segue to my second vc):
if #available(iOS 11.0, *) {
navigationController!.navigationBar.prefersLargeTitles = false
}
mapView.delegate = self
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
This is the code inside viewDidLoad
of my second vc (the segue leads to this vc):
if #available(iOS 11.0, *) {
navigationController!.navigationBar.prefersLargeTitles = true
}
They both use the same navigationController
. For my first vc I want the navBar preferresLargeTitles = false
and for my second I want the navBar to preferresLargeTitles = true
that's what I am doing inside the viewDidLoad
methods. The 5 lines about MapKit
and CoreLocation
shouldn't cause this effect but I don't know why this black view appears so I left these lines of code. How can I remove that black view which is appearing behind my navBar when the segue is performed? (when the segue is completed the black color disappears) (The black color in top right corner is what's bothering me)
Upvotes: 2
Views: 2816
Reputation: 230
Changing .backgroundColor
for navigationController.view
solved this issue for me.
override func viewDidLoad() {
super.viewDidLoad()
navigationController.view.backgroundColor = .systemBackground
}
Upvotes: 7
Reputation: 51
Changing .backgroundColor
for navigationBar.scrollEdgeAppearance
(UINavigatioBarAppearance
) solved this issue for me.
example:
let scrollEdgeAppearance = UINavigationBarAppearance()
scrollEdgeAppearance.backgroundColor = // your color or .clear
navigationBar.scrollEdgeAppearance = scrollEdgeAppearance
Upvotes: 1