【发布时间】:2016-12-23 11:06:07
【问题描述】:
我希望标签栏位于屏幕顶部。一篇文章建议执行以下操作(我将以下代码放在 UITabBarController 的 viewDidLoad() 中):
代码
let tabBar = self.tabBar
// yStatusBar indicates the height of the status bar
let yStatusBar = UIApplication.sharedApplication().statusBarFrame.size.height
// Set the size and the position in the screen of the tab bar
tabBar.frame = CGRectMake(0, yStatusBar, tabBar.frame.size.width, tabBar.frame.size.height)
这个解决方案有两个问题:
屏幕底部留下一个黑色区域,标签栏所在的位置
标签栏覆盖屏幕顶部的视图 - 该视图的约束是相对于设备的,但它们应该是相对于标签栏的。但是,当在 IB 中设计屏幕时,没有可关联的 Tab 栏。
有没有办法克服这些问题?附言我是IOS新手
【问题讨论】:
-
这违反了人机界面指南,可能不是一个好主意。如果你还在,请看答案:stackoverflow.com/questions/29579992/…
-
我的应用程序是为 Android 编写的,现在我正在将它移植到 iPhone。在 Android 中,这是大多数应用程序的工作方式。