Search code examples
iosswiftuinavigationbaruiviewanimationuinavigationitem

UI glitch (black flicker) on right side of navbar during transition


I have an app that has a uipageviewcontroller that is presented on initial launch of the app. On the last page of the uipageviewcontroller I present the main navigation controller with a TransitionCrossDissolve animation. While the animation is ongoing I get a tiny black background flicker on the right side of the navigation bar like this:

uinavigationbar transition

In the beginning I had the black flicker on the whole navigation bar, but after calling

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    self.navigationController?.navigationBar.layer.removeAllAnimations()

}

the problem almost went away.

Her is a gif of the problem before calling removeAllAnimations():

enter image description here

This i how I call for the animation on the last page of the uipageviewcontroller:

let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate

UIView.transitionWithView(appDelegate.window!, duration: 0.5, options: UIViewAnimationOptions.TransitionCrossDissolve , animations: { () in

        appDelegate.window!.rootViewController = appDelegate.mainNavigationController

}, completion: nil)

It may be important to not that I am using a procedure to remove the hairline at the bottom of the navbar. May this be the reason for all of this?

Ref: How to hide iOS7 UINavigationBar 1px bottom line

I would greatly appreciate any feedback on the issue.

Brgds


Solution

  • I was able to remove the black UI glitch by removing the animation on all subviews of the navigationbar. I think the problem was with the right UINavigationItem. Here is the code I used:

    let subviews = (self.navigationController?.navigationBar.subviews as [UIView])
        for subview: UIView in subviews {
            subview.layer.removeAllAnimations()
        }