2

我使用以下代码从应用程序委托添加了状态栏背景视图:

let view = UIView(frame: CGRect(x: 0.0, y: 0.0, width: UIScreen.mainScreen().bounds.size.width, height: 20.0))
view.backgroundColor = UIColor.blackColor()
self.window!.rootViewController!.view.addSubview(view)`

当我使用 时,问题就开始IQKeyboardManager了,当按下文本字段时,它会向上滑动添加的状态栏背景视图。它看起来像这样:

向上滑动背景视图

我将如何修复该状态栏位置?

4

1 回答 1

2

不要静态设置框架。获取状态栏的实际框架:

UIView(frame: UIApplication.sharedApplication().statusBarFrame).
于 2016-07-31T18:54:45.703 回答