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?
These are the best github repos I found:
https://github.com/forkingdog/FDFullscreenPopGesture https://github.com/kingiol/KDInteractiveNavigationController https://github.com/MoZhouqi/KMNavigationBarTransition
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
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With