简体   繁体   English

Ionic ReactApp - ios 状态栏颜色

[英]Ionic ReactApp - ios status bar color

We have an ionic react app, from which we built an ios app using capacitor.我们有一个离子反应应用程序,从中我们使用电容器构建了一个 ios 应用程序。

We have problem with our status bar color being white on a white background.我们的状态栏颜色在白色背景上呈白色时存在问题。

I tried looking around for fixes and found this: https://developer.apple.com/forums/thread/16771我试着四处寻找修复,发现: https://developer.apple.com/forums/thread/16771

But when I insert the code into appDelegate.swift, it says "Cannot find 'splitViewController' in scope. I tried few different imports, but nothing fixed this. What should we import so this solution works? Or, is there a better way to change color of ios status bar?但是当我将代码插入 appDelegate.swift 时,它显示“在 scope 中找不到 'splitViewController'。我尝试了几种不同的导入,但没有解决这个问题。我们应该导入什么才能使这个解决方案有效?或者,有没有更好的方法更改 ios 状态栏的颜色?

Please keep in mind that none of us knows swift very much.请记住,我们没有人非常了解 swift。

import UIKit 
import Capacitor 
import Firebase

@UIApplicationMain 

class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 

        FirebaseApp.configure() 

        // Override point for customization after application launch. 

        splitViewController.navigationController?.navigationBar.tintColor = UIColor.blackColor() 

        return true 

    }

...

Change it in your Info.plist file instead.改为在Info.plist文件中更改它。

...
<key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleDarkContent</string>
...

You can also do it using the interface directly in Xcode by navigating to App > General > Deployment Info > Status Bar Style您也可以直接使用 Xcode 中的界面执行此操作,方法是导航到App > General > Deployment Info > Status Bar Style

This of course will change the status bar across the entirety of your app.这当然会改变整个应用程序的状态栏。

If you would like to do something a little more dynamic, eg change the color based on the screen the user is on, you can follow the CapacitorJS documentation here: https://capacitorjs.com/docs/apis/status-bar如果您想做一些更动态的事情,例如根据用户所在的屏幕更改颜色,您可以在此处遵循 CapacitorJS 文档: https://capacitorjs.com/docs/apis/status-bar

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

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