user1445205
user1445205

Reputation:

Adjust UINavigationBar height with Auto Layout

I have to following code to adjust the height of my UINavigationBar:

[self.navigationController.navigationBar setFrame:CGRectMake(0, 0, self.view.frame.size.width, 90)];

This works only for a split second when pushing the view before the bar resizes to its default height. I think this is because Auto Layout is enabled, but I'm not sure. How would I keep my UINavigationBar at my desired height without it returning to its default state?

Upvotes: 0

Views: 1266

Answers (1)

Dave Lyon
Dave Lyon

Reputation: 611

Apple provides some great sample code demonstrating common ways to manage the navigation bar in the Customizing UINavigationBar project. That's probably the best place to find the specific setup for what you're trying to do.

To answer the specific question, you would need to create a custom subclass of UINavigationBar and override the height in layoutSubviews since ultimately, Apple's code will continually attempt to reset the size during transitions.

Upvotes: 1

Related Questions