How to change the height of the UINavigationBar, allowing you to install the root view controller?

I want to resize a UINavigationBar . I stumbled upon several previously asked questions, but I think this is completely different than those.

Found that I have to subclass UINavigationBar and where I have to update its height. But then, to use this subclassical navigation bar, I have to use the UINavigationController method below.

There he is:

 - (id) initWithNavigationBarClass:(nullable Class)navigationBarClass toolbarClass:(nullable Class)toolbarClass; 

if I used this to install my subclass navigation bar, then how do I set it to rootViewController using the method below:

 - (id) initWithRootViewController:(UIViewController *)rootViewController; 

Is there any other way, I can achieve my goal of resizing the height of the navigation bar, and also install a root view controller in it?

0
ios objective-c resize uinavigationcontroller uinavigationbar
Jul 04 '15 at 7:08
source share
2 answers

Subclassing UINavigationBar does the trick!

 #import <UIKit/UIKit.h> @interface BaseNavigationBar : UINavigationBar @end @implementation BaseNavigationBar - (CGSize)sizeThatFits:(CGSize)size {return CGSizeMake(self.superview.bounds.size.width, 24.f);} @end 
+1
Aug 12 '15 at 11:23
source share

In the documentation, they say that the viewControllers property returns an array, which at index 0 contains the root view controller.
I think that if you pass a VC array to this property, then an object with a zero index will be considered the root. Or just an array of one element.

0
Jul 04 '15 at 8:06
source share



All Articles