Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent view resizing/transform when UINavigationBar hides/shows

I have an application with a tab bar and a navigation bar. I push a view controller that is used to show photos, one at a time. It initially shows the bars and forward/back controls; after a delay, these hide, using setNavigationBarHidden:animated: and a custom transform (CGAffineTransformMakeTranslation) on the tab bar. This works, but the view controllers view , which shows the photo, leaps up and down. The same is true if I leave the tab bar out of the equation.

How can I prevent the UINavigationBar from moving my view around? I would like the photo to stay fixed in the screen, with the nav bar dropping down over the top segment of it.

like image 401
Paul Lynch Avatar asked May 19 '10 11:05

Paul Lynch


2 Answers

Had this issue and fixed it with a class that inherited from UINavigationController

-(void)viewWillAppear:(BOOL)animated
{
    self.navigationBar.translucent = YES;
}

Worked great for me, didn't had to set style to UIBarStyleBlackTranslucent. So it did kept my colors.

like image 114
MichalMazurek Avatar answered Oct 02 '22 03:10

MichalMazurek


[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];

this seemed to do the trick for me!

like image 30
Stultus Avatar answered Oct 02 '22 01:10

Stultus