简体   繁体   English

如何使状态栏与导航栏的颜色相同?

[英]How can I make my status bar be the same colour as my navigation bar?

I want my navigation bar to look similar to that of the Twitter app. 我希望我的导航栏看起来类似于Twitter应用程序。 My app only has three different views, so I don't mind doing each one manually. 我的应用程序只有三个不同的视图,因此我不介意手动执行每个视图。 How do I go about doing this? 我该怎么做呢?

Create a view, put it where the status bar will be, and set its background color to which ever color you prefer. 创建一个视图,将其放在状态栏所在的位置,然后将其背景色设置为您喜欢的任何一种颜色。

let statusBarView = UIView(frame: UIApplication.sharedApplication().statusBarFrame)
statusBarView.backgroundColor = UIColor.greenColor() // Replace with color you desire
self.view.addSubview(statusBarView)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM