ios - iOS 13 UITabBar 重新定位到顶部
问题描述
我已按照此答案将标签栏重新定位到页面顶部。在 iOS 13 发布之前,它一直运行良好。在 iOS 13 中,标签栏在屏幕底部可见。我应该使用任何其他解决方法吗?
有没有人面临同样的问题?
更新:
下面是我在我的应用程序中使用的一段代码:
- (void) viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
[self.tabBar invalidateIntrinsicContentSize];
// Just a quick fix for making this to happen for iOS versions between 11.0 to 11.1
// Updating the frame in Main queue.
dispatch_async(dispatch_get_main_queue(), ^{
[self changeTabBarPosition];
});
// Set the translucent property to NO then back to YES to
// force the UITabBar to reblur, otherwise part of the
// new frame will be completely transparent if we rotate
// from a landscape orientation to a portrait orientation.
self.tabBar.translucent = NO;
self.tabBar.translucent = YES;
}
- (void)changeTabBarPosition {
CGFloat tabSize = 44.0;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation)) {
tabSize = 32.0;
}
CGRect tabFrame = self.tabBar.frame;
tabFrame.size.height = tabSize;
tabFrame.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height;
self.tabBar.frame = tabFrame;
}
解决方案
我只是在 iOS 13 上测试了下面的代码。它仍然有效。
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.tabBarController.tabBar.frame = CGRectMake(0, 0, self.view.frame.size.width, self.tabBarController.tabBar.frame.size.height);
}
推荐阅读
- javascript - ERR_STREAM_WRITE_AFTER_END 使用请求承诺节点 Js
- php - 查询不适用于数组中的变量作为条件
- mysql - MySQL Union Statement 不起作用,正在努力寻找原因
- reactjs - 使用 React JS 和时刻在生日字段上编辑表单中的无效日期
- python - 我有一个数据框,其数据列从 2005 年 1 月 1 日到 2014 年 12 月 31 日。我如何对列进行排序?
- matlab - 无法识别的函数或变量“x”。在matlab中
- typescript - 打字稿索引签名参数类型必须是“字符串”或“数字”
- javascript - 未记录从 Firebase 读取的数据
- python - 从列表中删除完全匹配的元素
- asp.net - 在 ASP.NET 4.8 中等待后 HttpContext 为空