9
votes

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

2
efremidze, how did you end up accomplishing this?SAHM
I've been using this library: github.com/MoZhouqi/KMNavigationBarTransitionefremidze
I have implemented a configureable framework consistent with your request : github.com/yiplee/YPNavigationBarTransition Checkout the example project for details.yiplee

2 Answers

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
    })
}