Custom background color for status bar in iOS app created with Xcode and Swift

给你一囗甜甜゛ 提交于 2019-12-12 03:23:53

问题


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?


回答1:


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.




回答2:


Try this, it will help.

let demoView = UIView()
demoView.frame = CGRectMake(0, 0, 320, 22)
demoView.backgroundColor = UIColor.redColor()
self.view.addSubview(demoView)


来源:https://stackoverflow.com/questions/37662704/custom-background-color-for-status-bar-in-ios-app-written-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!