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?
9
votes
efremidze, how did you end up accomplishing this?
– SAHM
I've been using this library: github.com/MoZhouqi/KMNavigationBarTransition
– efremidze
I have implemented a configureable framework consistent with your request : github.com/yiplee/YPNavigationBarTransition Checkout the example project for details.
– yiplee
2 Answers
9
votes
These are the best github repos I found:
https://github.com/forkingdog/FDFullscreenPopGesture https://github.com/kingiol/KDInteractiveNavigationController https://github.com/MoZhouqi/KMNavigationBarTransition
4
votes
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
})
}