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

查看:38
本文介绍了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.

请看附上的图片:

半透明(关闭 - 否):

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 设置为 NO 时,会在 iOS7 中发生这种情况.iOS 试图变得聪明并说嘿,标签栏不是半透明的,所以我们最好把所有东西都放在上面".通过将位于标签栏控制器内的导航控制器内的视图控制器的 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.

示例(未实际运行):

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

顺便说一句,我最喜欢不透明的标签栏.

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

编辑

正如安迪在下面提到的,这个标志不必在代码中设置.如果那是你使用的,你可以在 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天全站免登陆