MoZhouqi / KMNavigationBarTransition

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.
MIT License
3.38k stars 457 forks source link

Basic master detail animation not functioning. #102

Closed thexande closed 6 years ago

thexande commented 6 years ago

example repo here: https://github.com/thexande/nav_bar_color_transition/tree/master/nav_bar_color_transition

Any idea why the transition works once, but after detail view controller gets popped the navigation bar color remains the same?

Here is my basic implementation:

class MasterViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        title = "Master"
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Detail", style: .plain, target: self, action: #selector(pressedDetail))
        navigationController?.navigationBar.setBackgroundImage(UIImage(color: UIColor.red), for: .default)
    }

    @objc func pressedDetail() {
        navigationController?.pushViewController(DetailViewController(), animated: true)
    }
}

class DetailViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        title = "Detail"
        navigationController?.navigationBar.setBackgroundImage(UIImage(color: UIColor.green), for: .default)
    }
}

Thoughts?

nav_transition

MoZhouqi commented 6 years ago

Hi, maybe you should add pod 'KMNavigationBarTransition' in the nav_bar_color_transition target.