Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transition to Transparent UINavigationBar (Apple Music like Navigation Bar)

I'm trying to copy the iOS Music app push/pop transition from a semi transparent to a transparent UINavigationBar, while keeping the UIBarButtonItems visible. Since the navigation bar doesn't move itself, I believe you need to set the UINavigationBar transparent for both UIViewControllers and add a subview to the UIViewController under the transparent UINavigationBar to simulate a semi transparent UINavigationBar. Any solutions for this issue?

iOS Music app transition

like image 743
efremidze Avatar asked Jul 07 '15 22:07

efremidze


2 Answers

These are the best github repos I found:

https://github.com/forkingdog/FDFullscreenPopGesture https://github.com/kingiol/KDInteractiveNavigationController https://github.com/MoZhouqi/KMNavigationBarTransition

like image 103
efremidze Avatar answered Oct 26 '22 00:10

efremidze


On your details controller put this code

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

    guard self.navigationController?.topViewController === self else {return}

    self.transitionCoordinator()?.animateAlongsideTransition({ [weak self](context) in
        self?.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
        self?.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)

        }, completion: { context in
    })
}

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

    guard self.navigationController?.topViewController === self else {return}

    self.transitionCoordinator()?.animateAlongsideTransition({ [weak self](context) in
        self?.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
        self?.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: .Default)
        }, completion: { context in
    })
}
like image 32
Emil Landron Avatar answered Oct 26 '22 00:10

Emil Landron