【发布时间】:2016-09-26 09:39:19
【问题描述】:
在我的 UITableViewController 中滚动几个项目会使单元格出现在我的UIStatusBar 后面。我尝试使用此方法解决问题:
var bounds = self.view.bounds
bounds.origin.y -= 20.0;
self.view.bounds = bounds
// Create a solid color background for the status bar
let statusFrame = CGRect(x: 0, y: -20, width: bounds.size.width, height: 20)
let statusBar = UIView(frame: statusFrame)
statusBar.backgroundColor = UIColor.red
self.view.addSubview(statusBar)
这将在滚动之前给我一个红条。它在滚动一点后消失。我还尝试将 tableView 的 contentInset 设置为UIApplication.shared.statusBarFrame.height,但也做了同样的事情。
保留导航栏很重要。我的 TableViewController 也嵌入在 UINavigationController
有什么想法吗?
【问题讨论】:
-
滚动结束的状态,还是隐藏栏还是显示?你的平台运行的是什么,只有 iOS 8 以上还是所有版本?
-
ios8 及以上。它需要始终保持稳定。是否滚动。 @罗南
-
你只是想把状态栏的背景颜色改成红色,并确保它不会自动改变,对吧?
-
@ronan 不,它是红色的并不重要。它只需要是实心/不透明的,这样人们就看不到它后面的细胞。
-
self.navigationController?.navigationBar.isTranslucent = false怎么样?
标签: ios uitableview uistatusbar