Custom background color for status bar in iOS app

2019-02-28 01:54发布

I already googled a little bit but without success. I want to have a custom background color for the status bar in all my ViewControllers (only in portrait mode). The ViewControllers are managed with a TabBarController.

Does anybody know how to do that? Maybe anybody has a code sample?

2条回答
三岁会撩人
2楼-- · 2019-02-28 02:09

I already solved the problem myself by putting a UIView below the Status bar and set the background color. But I had to clear all constraints and add them again to make the UIView hiding in landscape mode.

查看更多
不美不萌又怎样
3楼-- · 2019-02-28 02:25

Try this, it will help.

let demoView = UIView()
demoView.frame = CGRectMake(0, 0, 320, 22)
demoView.backgroundColor = UIColor.redColor()
self.view.addSubview(demoView)
查看更多
登录 后发表回答