Transitioning between transparent navigation bar to translucent

后端 未结 2 1087
没有蜡笔的小新
没有蜡笔的小新 2021-01-29 23:17

In Apple\'s recently released Remote app I noticed the way in which the navigation bar behaves is unique and I haven\'t been able reproduce it. When popping the Now Playing view

2条回答
  •  清歌不尽
    2021-01-29 23:39

    Instead of hiding and showing the navigation bar, you can update the alpha for the navigation bar. It will animate smoothly during the transition. For the view controller with transparent nav bar, instead of modifying the nav bar, create a navbar (or just the back button and title etc.) manually in the second controller's view. We will then hide the navbar when transitioning from first view controller to the second one.

    On your first controller's viewWillDisappear and on your second view controller's viewWillAppear:, set the navigation bar alpha to zero using self.navigationController.navigationBar.alpha = 0;. Since this is in animation block, this will make the navigation bar disappear during the push animation.

    Set the alpha back to one in first controller's viewWillAppear and second controller viewWillDisappear.

提交回复
热议问题