iOS 7 TabBar半透明问题 [英] iOS 7 TabBar Translucent issue

查看:231
本文介绍了iOS 7 TabBar半透明问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,当我在TabBar上关闭半透明框时,有些东西阻挡了我的一些视图。

I have an issue, when I set the translucent box off on a TabBar, there is something blocking some of my view.

看起来它是某种额外的标签栏或我甚至不知道。我正在使用故事板。

It looks like it's a sort of extra tab bar or I don't even know. I'm using storyboard.

请参阅附件中的图片:

使用半透明(OFF - NO):

With Translucent (OFF - NO):

使用半透明(ON或YES):

With Translucent (ON or YES):

有人知道为什么会这样吗?

Does anybody know why it looks like this?

谢谢

PS:你喜欢哪个tabBar?黑色或此一个:

PS: Which tabBar do you guys like? Black or this one:

推荐答案

当您将 tabBar.translucent 设置为<时,会在iOS7中发生这种情况code> NO 。 iOS正试图变得聪明,并说嘿,tabbar不是半透明的,所以我们最好把所有东西都放在它上面。通过将导航控制器内的视图控制器的 extendedLayoutIncludesOpaqueBars 属性设置为 YES 来修复它。

This happens in iOS7 when you set tabBar.translucent to NO. iOS is trying to be smart and say "hey the tabbar is not translucent so we better push everything up on top of it". Fix it by setting the extendedLayoutIncludesOpaqueBars property of the view controller inside the navigation controller which is inside the tabbar controller to YES.

示例(实际上没有运行):

Example (not actually ran):

UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.tabBar.barStyle = UIBarStyleBlack;
tabBarController.tabBar.translucent = NO;

UIViewController *viewController = [[UIViewController alloc] init];
viewController.extendedLayoutIncludesOpaqueBars = YES; // <-- This is important!!!!!!

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: viewController];

tabBarController.viewControllers = @[navigationController];

资料来源: https://web.archive.org/web/20160405135605/https:// developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/AppearanceCustomization.html

而BTW,我喜欢非半透明的tabbar最好的。

And BTW, I like the non-translucent tabbar the best.

编辑

正如Andy在下面提到的,这个标志没有必须在代码中设置。如果你使用的话,你可以在IB中设置它。

As Andy mentioned below, this flag does not have to be set in code. You can set it in IB if that's what you use.

这篇关于iOS 7 TabBar半透明问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆