iPad: Have child navbar be a different color than the main navbar

时间:2019-03-19 15:06:23

标签: ios swift ipad uinavigationcontroller uinavigationbar

We are currently working on and ipad app that has a navigation controller. When we tap a button and open a second view - the view inherits the main navigation controller. We want to be able to set the second navigation controllers color.

We are using UINavigationBar.appearance(whenContainedInInstancesOf: [CustomNavigationController.self]) to change the color. See screen shot.

Hierarchy: View loads -> Segue to add in the side bar(buttons view) -> Tap a button -> Opens a secondary view and passes in the navcontroller.

Screen shot

1 个答案:

答案 0 :(得分:1)

In the viewWillAppear method of the view controller you can set the nav bar's tintColor. In viewWillDisappear you can reset the tintColor to its previous color.