How to change Status Bar Color on iOS 13 using Objective C?

How can I change the statuds bar color on ios13 using Objecticve C? Thanks in advance.

Replies

**** good question.

It's quite easy actually:


UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame] ;
statusBar.backgroundColor = [UIColor whiteColor];
[[UIApplication sharedApplication].keyWindow addSubview:statusBar];

It is applicable the same code to Swift also?

Sure:


let statusBar = UIView(frame(UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame)!)

statusBar.backgroundColor = UIColor.whiteColor()

UIApplication.shared.keyWindow?.addSubview(statusBar)

Sadly keyWindow was deprecated in iOS 13.0

you can use like this as well :



let statusBar = UIView()

statusBar.frame = UIApplication.shared.statusBarFrame

statusBar.backgroundColor = color

UIApplication.shared.keyWindow?.addSubview(statusBar)