I created a custom UIStoryboardSegue , but when it unwinds, it seems that my UINavigationBar will turn black, and then go back to the correct color. See below GIF.

My custom segue just makes the new ViewController go down and down.
Here is the UIStoryboardSegue code:
import UIKit class SlideDownSegue: UIStoryboardSegue { var duration: Double = 0.5 override func perform() { let screenHeight = UIScreen.main.bounds.size.height let toVC = self.destination let fromVC = self.source toVC.view.transform = CGAffineTransform(translationX: 0, y: -screenHeight) UIApplication.shared.keyWindow?.insertSubview(toVC.view, aboveSubview: fromVC.view) UIView.animate(withDuration: duration, delay: 0, options: UIViewAnimationOptions.curveEaseInOut, animations: { toVC.view.transform = CGAffineTransform.identity }, completion: { success in fromVC.present(toVC, animated: false, completion: nil) }) } } class UnwindSlideDownSegue: UIStoryboardSegue { override func perform() { let screenHeight = UIScreen.main.bounds.size.height let toVC = self.destination let fromVC = self.source.parent! fromVC.view.superview?.insertSubview(toVC.view, at: 0) UIView.animate(withDuration: 0.5, delay: 0, options: UIViewAnimationOptions.curveEaseInOut, animations: { fromVC.view.transform = CGAffineTransform(translationX: 0, y: -screenHeight - 100) }, completion: { success in fromVC.dismiss(animated: false, completion: nil) }) } }
If I allow the default unwinding when it just leaves, going to the bottom of the screen, but retaining its custom to display the new view, the UINavigationBar maintains its correct color, it is only when I used my code that during the animation the UINavigationBar turns black.
Any clues would be greatly appreciated.
--- EDIT ---
I played around with it a bit if I go to AppDelegate and change UINavigationBar.appearance().isTranslucent = false to true, instead I get a white background, but then it just appears that the navigation bar appears suddenly. I am wondering if this is for some reason unloaded and then loaded back when the View Controller is active.
--- EDIT 2 ---
I can fix this with a hack. In the AppDelegate inside the func application(... didFinishLaunchingWithOptions ...) I added to self.window?.backgroundColor = UIColor.{your color} , but all that does is that the black part now appears in my color, by for some reason, the navigation bar still disappears during segue.
ios11 swift4 uistoryboardsegue uinavigationbar xcode9
Jason brady
source share