开发者

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

开发者 https://www.devze.com 2022-12-31 01:22 出处:网络
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, thes

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 i开发者_运维问答f 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.


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.


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

this seemed to do the trick for me!


I know this is an old question, but I accomplished that by disabling 'Autoresize Subviews' in Interface Builder

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


I haven't been able to find a proper way to handle this except to set the navigationBar style to translucent as in:

theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

Other than creating another navigation bar and adding buttons to them, that's the best (and it seems to be what Apple does as well in it's Photo app)

0

精彩评论

暂无评论...
验证码 换一张
取 消