我有一个问题,当我在 TabBar 上关闭半透明框时,有东西挡住了我的部分视线。
它看起来像是一种额外的标签栏,或者我什至不知道。我正在使用 Storyboard。
请看附件图片:
半透明(关闭 - 否):
半透明(ON 或 YES):
有人知道为什么会这样吗?
谢谢
PS:你们喜欢哪个tabBar?黑色还是这个:
最佳答案
当您将 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];
顺便说一句,我最喜欢非半透明的标签栏。
编辑
正如安迪在下面提到的,这个标志不必在代码中设置。如果那是您使用的,您可以在 IB 中设置它。
关于iphone - iOS 7 TabBar 半透明问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20979281/