iphone - iOS 7 TabBar 半透明问题

标签 iphone objective-c ios7 uitabbar

我有一个问题,当我在 TabBar 上关闭半透明框时,有东西挡住了我的部分视线。

它看起来像是一种额外的标签栏,或者我什至不知道。我正在使用 Storyboard。

请看附件图片:

半透明(关闭 - 否):

With Translucent (OFF - NO)

半透明(ON 或 YES):

With Translucent (ON or YES)

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

谢谢

PS:你们喜欢哪个tabBar?黑色还是这个:

enter image description here

最佳答案

当您将 tabBar.translucent 设置为 NO 时,这会在 iOS7 中发生。 iOS 试图变得聪明,并说“嘿,标签栏不是半透明的,所以我们最好将所有内容都推到它上面”。通过将标签栏 Controller 内的导航 Controller 内的 View Controller 的 extendedLayoutIncludesOpaqueBars 属性设置为 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

顺便说一句,我最喜欢非半透明的标签栏。

编辑

正如安迪在下面提到的,这个标志不必在代码中设置。如果那是您使用的,您可以在 IB 中设置它。

关于iphone - iOS 7 TabBar 半透明问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20979281/

相关文章:

iphone - 推送通知指南?

ios7 - 自定义转场 VS 自定义过渡

ios - 在 iOS 7 map 上显示路线 : addOverlay has no effect

ios - 仅更改一种特定的 UITabBarItem 色调颜色

iphone - 如果不再需要,如何正确从其 super View 中删除 View ?

iphone - Xcode 4.2 在出错时显示错误的代码行

iphone - 做一个坐标平面

objective-c - ios - UIActivityIndi​​catorView 是否应该默认显示?

objective-c - 改进在文本正文中查找 URL 的算法 - obj-c

iphone - 简单的 UITextView 崩溃