Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using UIAppearance to move UINavigationBar

I am trying to increase the height of the UINavigationBar via UIAppearance

The height itself does change but part of the bar is obscured by the device status bar. I would like to move the bar down 22 pixels so it is fully visible:

[[UINavigationBar appearance] setFrame:CGRectMake([[UINavigationBar appearance] frame].origin.x, 22, [[UINavigationBar appearance] frame].size.width, 103)];

And I also set the autoresizing mask

[[UINavigationBar appearance] setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin];

But the bar is not translated. Is there another way or another step here?

like image 493
Andrew Lauer Barinov Avatar asked Jun 06 '12 16:06

Andrew Lauer Barinov


People also ask

How do I change the navigation bar on my Iphone?

Change the Bar Style A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.

How do I use the navigation bar in Xcode?

Start with Navigation ControllerCreate a single view application in Xcode. Add two view controller into your storyboard. Create two different swift files for those view controllers and set identifiers for them. Take a button in each view controller, set constrain for them and customize as you want.

What is barTintColor?

The tint color to apply to the navigation bar background.


1 Answers

You can move down only title by this:

[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:5 forBarMetrics:UIBarMetricsDefault];
like image 101
Michal Zaborowski Avatar answered Oct 05 '22 07:10

Michal Zaborowski