ios - 如何在 Swift 和 iOS 9 中使整个项目的导航栏变黑

标签 ios swift ios9 statusbar

我想将整个项目的状态栏设置为黑色。我的项目中有分页、模态视图、导航堆栈。有没有办法将完整项目的状态栏设置为黑色。我在 Android 应用程序中见过这个。我尝试在 AppDelegate 中将状态栏设置为 Light,在 plist 中将基于 View Controller 的导航栏设置为 NO/YES。似乎什么都不起作用。

最佳答案

调用此表单application:didFinishLaunchingWithOptions应该可以。

func setStatusBarBackgroundColor(color: UIColor) {
guard  let statusBar = UIApplication.sharedApplication().valueForKey("statusBarWindow")?.valueForKey("statusBar") as? UIView else {
    return
}

statusBar.backgroundColor = color
}

关于ios - 如何在 Swift 和 iOS 9 中使整个项目的导航栏变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38935633/

相关文章:

ios - 在 Wax 中访问 Objective-C 实例

ios - 如何在 Swift 3 中制作嵌套的 JSON

ios - 解码 JSON 时在两个结构中使用相同的编码 key

swift - 自定义 UITableViewCell 只有两个创建的类之一没有初始化错误。 swift

iphone - 防止在 MKMapView 中滚动,缩放时也是如此

swift - 在单个 SKSpriteNode 上分割 TouchMoved

swift - 如何从 View 中退出FirstResponder,但当应用程序在 Swift 中进入后台状态时?

ios9 - 使用 FBSDKProfilePictureView 在 iOS 9 中不显示 Facebook 个人资料图片

javascript - 消息处理程序在 iOS 9 的 WKWebView 中不起作用

android - flutter 在外部打开文件,例如在 ios 上 "open in"