How to prevent view resizing/transform when UINavi

2020-06-17 05:47发布

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.

4条回答
小情绪 Triste *
2楼-- · 2020-06-17 06:15

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)

查看更多
欢心
3楼-- · 2020-06-17 06:25

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

alt text

查看更多
女痞
4楼-- · 2020-06-17 06:28
[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];

this seemed to do the trick for me!

查看更多
叼着烟拽天下
5楼-- · 2020-06-17 06:35

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.

查看更多
登录 后发表回答