bikram sapkota
bikram sapkota

Reputation: 1124

Fix status bar position

I added a status bar background view from app delegate with the following code:

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)`

The problem starts when I use IQKeyboardManager, it slides up that added status bar background view when a text field is pressed. It appears like this:

slid up background view

How would I fix that status bar position?

Upvotes: 2

Views: 604

Answers (1)

Daniel Storm
Daniel Storm

Reputation: 18898

Don't set the frame statically. Get the actual frame of the status bar:

UIView(frame: UIApplication.sharedApplication().statusBarFrame).

Upvotes: 2

Related Questions