How to get height of navigation bar in child view?

I have a navigation controller based user interface that contains a view

MainView 

MainView contains a child view

 MainView ChildView 

and ChildView contains a preview

 MainView ChildView SubView 

When I push ChildView on the stack, I need to get the height of the navigation bar in the SubViewController in order to resize the content. In SubViewController I tried

 self.navigationController.navigationBar.frame.size.height 

and

 self.parentViewController.navigationController.navigationBar.frame.size.height 

and not one of them contains the height of the navigation bar. I would prefer that the height, rather than the hard code, be 44.0.

+4
source share
1 answer

You may need to do this in the viewDidLoad method. You need to wait until all the components of the user interface are loaded when you get the dimensions. (This is just my hunch.)

0
source

Source: https://habr.com/ru/post/1387078/


All Articles