0

我在使用 XCode9.2 的 iPhoneX 上遇到问题,但使用 XCode8 运行应用程序没有问题。

根据我的发现,UITabBar 的高度设置为 49。

iPhoneX 的 UITabBarButton 高度为 14,但 iPhone 6 的 UITabBarButton 为 49

任何想法如何在 XCode9 中解决这个问题?

以下是它在 iPhone X 上的显示方式:

iPhone X iOS 11.2

以下是它在 iPhone 6 上的显示方式:

iPhone 6 iOS 11.2

4

1 回答 1

0
viewController.hidesBottomBarWhenPushed = YES;

我猜你用过。

所以就出现了这个问题。

你需要在

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated

添加此代码:

if (@available(iOS 11.0, *)){

    CGFloat height = [UIApplication sharedApplication].statusBarFrame.size.height > 20.0f ? 83.0f : 49.0f;

    CGRect frame = CGRectMake(0.0f, [UIScreen mainScreen].applicationFrame.size.height - height, [UIScreen mainScreen].applicationFrame.size.width, height);

    self.tabBarController.tabBar.frame = frame;
}
于 2018-09-18T10:19:07.580 回答