iPhone X UITabBarButton错位

问题描述 投票:0回答:1

我在使用XCode 9.2的iPhone上遇到了问题但是使用XCode 8运行应用程序没有问题。

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

iPhone的UITabBarButton高度为14,而iPhone 6的UITabBarButton为49

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

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

iPhone X iOS 11.2

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

iPhone 6 iOS 11.2

ios11 uitabbar uitabbaritem iphone-x xcode9.2
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;
}
© www.soinside.com 2019 - 2024. All rights reserved.