2

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?

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
bikram sapkota
  • 1,106
  • 1
  • 13
  • 18

1 Answers1

2

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

UIView(frame: UIApplication.sharedApplication().statusBarFrame).
Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
  • according to your suggestion i set view frame like this let view = UIView(frame: UIApplication.sharedApplication().statusBarFrame.standardized) view.backgroundColor = UIColor.blackColor() self.window!.rootViewController!.view.addSubview(view) and added that subview to rootviewcontroller but it's not working – bikram sapkota Aug 01 '16 at 01:01