离子状态栏白底白字

Posted

技术标签:

【中文标题】离子状态栏白底白字【英文标题】:Ionic Statusbar White on White 【发布时间】:2018-03-06 22:30:56 【问题描述】:

自从这次新的 XCode 更新以来,有没有人遇到过白色状态栏?

在更新之前,此代码正在运行...

statusBar.styleBlackTranslucent();

...现在我得到一个带有白色文本的白色条。 (see screenshot)

相关调试信息:

statusBar.hide(); 

正在运行...所以我知道 cordova-plugin-statusbar 在某种程度上仍在工作。

但是当我取出所有状态栏代码并从 XCode 导出时,该栏仍然是白色背景的白色文本。

当然,更新发生在我即将推出 Beta 版的那一天。

这是我的 config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.XX" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>XX</name>
    <description>Create, experience, share.</description>
    <author email="XX@XX.com" href="https://XX.com/">Rob Gungor</author>
    <content src="index.html" />
    <access origin="*" />
    <allow-navigation href="http://ionic.local/*" />
    <allow-navigation href="http://192.168.11.58:8100" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="webviewbounce" value="true" />
    <preference name="UIWebViewBounce" value="true" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="android-minSdkVersion" value="16" />
    <preference name="BackupWebStorage" value="cloud" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="600" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="3000" />
    <preference name="FadeSplashScreenDuration" value="950" />
    <preference name="KeyboardDisplayRequiresUserAction" value="false" />
    <preference name="Fullscreen" value="true" />
    <platform name="android">
        <allow-intent href="market:*" />
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon  src="resources/ios/icon/icon.png"  />
        <icon  src="resources/ios/icon/icon@2x.png"  />
        <icon  src="resources/ios/icon/icon-40.png"  />
        <icon  src="resources/ios/icon/icon-40@2x.png"  />
        <icon  src="resources/ios/icon/icon-40@3x.png"  />
        <icon  src="resources/ios/icon/icon-50.png"  />
        <icon  src="resources/ios/icon/icon-50@2x.png"  />
        <icon  src="resources/ios/icon/icon-60.png"  />
        <icon  src="resources/ios/icon/icon-60@2x.png"  />
        <icon  src="resources/ios/icon/icon-60@3x.png"  />
        <icon  src="resources/ios/icon/icon-72.png"  />
        <icon  src="resources/ios/icon/icon-72@2x.png"  />
        <icon  src="resources/ios/icon/icon-76.png"  />
        <icon  src="resources/ios/icon/icon-76@2x.png"  />
        <icon  src="resources/ios/icon/icon-83.5@2x.png"  />
        <icon  src="resources/ios/icon/icon-small.png"  />
        <icon  src="resources/ios/icon/icon-small@2x.png"  />
        <icon  src="resources/ios/icon/icon-small@3x.png"  />
        <splash  src="resources/ios/splash/Default-568h@2x~iphone.png"  />
        <splash  src="resources/ios/splash/Default-667h.png"  />
        <splash  src="resources/ios/splash/Default-736h.png"  />
        <splash  src="resources/ios/splash/Default-Landscape-736h.png"  />
        <splash  src="resources/ios/splash/Default-Landscape@2x~ipad.png"  />
        <splash  src="resources/ios/splash/Default-Landscape@~ipadpro.png"  />
        <splash  src="resources/ios/splash/Default-Landscape~ipad.png"  />
        <splash  src="resources/ios/splash/Default-Portrait@2x~ipad.png"  />
        <splash  src="resources/ios/splash/Default-Portrait@~ipadpro.png"  />
        <splash  src="resources/ios/splash/Default-Portrait~ipad.png"  />
        <splash  src="resources/ios/splash/Default@2x~iphone.png"  />
        <splash  src="resources/ios/splash/Default~iphone.png"  />
        <icon  src="resources/ios/icon/icon-1024.png"  />
        <splash  src="resources/ios/splash/Default@2x~universal~anyany.png"  />
    </platform>
    <preference name="GOOGLE_PLUS_CLIENT_ID" value="XX" />
    <engine name="android" spec="^6.2.3" />
    <engine name="browser" spec="^4.1.0" />
    <engine name="ios" spec="^4.4.0" />
    <plugin name="com.telerik.plugins.nativepagetransitions" spec="^0.6.5" />
    <plugin name="cordova-fabric-plugin" spec="^1.1.9">
        <variable name="FABRIC_API_KEY" value="XX" />
        <variable name="FABRIC_API_SECRET" value="XX" />
    </plugin>
    <plugin name="cordova-plugin-admobpro" spec="^2.29.22" />
    <plugin name="cordova-plugin-cocoapod-support" spec="^1.3.0" />
    <plugin name="cordova-plugin-console" spec="^1.0.7" />
    <plugin name="cordova-plugin-device" spec="^1.1.6" />
    <plugin name="cordova-plugin-facebook4" spec="^1.9.1">
        <variable name="APP_ID" value="XX" />
        <variable name="APP_NAME" value="  &#xA;XX" />
    </plugin>
    <plugin name="cordova-plugin-firebase" spec="^0.1.24" />
    <plugin name="cordova-plugin-googleplus" spec="git+https://github.com/mzealey/cordova-plugin-googleplus.git">
        <variable name="REVERSED_CLIENT_ID" value="XX" />
    </plugin>
    <plugin name="cordova-plugin-ionic" spec="^1.1.8">
        <variable name="APP_ID" value="XX" />
        <variable name="CHANNEL_NAME" value="Master" />
        <variable name="UPDATE_METHOD" value="background" />
        <variable name="UPDATE_API" value="https://api.ionicjs.com" />
        <variable name="MAX_STORE" value="2" />
    </plugin>
    <plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
    <plugin name="cordova-plugin-statusbar" spec="git+https://github.com/apache/cordova-plugin-statusbar.git" />
    <plugin name="cordova-plugin-taptic-engine" spec="^2.1.0" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
    <plugin name="cordova-wheel-selector-plugin" spec="^1.0.9" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
</widget>

Here's a screenshot of my info panel in XCode

谢谢你的宝贝。 xo 抢

【问题讨论】:

【参考方案1】:

Rob 的答案就是解决方案。但是,使用 cordova-plugin-wkwebview-engine,我的应用程序无法正常工作。删除插件使应用程序恢复正常,状态栏问题全部消失。所以;

我删除了状态栏插件:

ionic cordova plugin remove cordova-plugin-statusbar

我安装了以下三个插件:

ionic cordova plugin add cordova-plugin-disable-ios11-statusbar
ionic cordova plugin add cordova-plugin-statusbar

然后调用

ionic cordova platform remove ios
ionic cordova platform add ios

谢谢罗伯!

更新: 找到了更清洁的解决方案。你只需要

cordova-plugin-statusbar

在 index.html 中,只需将“viewport-fit=cover”添加到 head 中的 viewport 元数据:

<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width, viewport-fit=cover">

就是这样

【讨论】:

【参考方案2】:

我安装了以下三个插件:

ionic cordova plugin add cordova-plugin-disable-ios11-statusbar
ionic cordova plugin add cordova-plugin-statusbar
ionic cordova plugin add cordova-plugin-wkwebview-engine

然后调用

ionic cordova platform remove ios
ionic cordova platform add ios

然后它对我有用 (不要问为什么)

【讨论】:

【参考方案3】:

我做了以下事情,它解决了所有相关的设计问题 ios。

1)Install/upgrade WKWebView
  ionic cordova plugin add cordova-plugin-ionic-webview --save

2) Add these line in config.xml
<feature name="CDVWKWebViewEngine">
        <param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

3) Add viewport-fit=cover in index.html
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">

【讨论】:

【参考方案4】:

请使用 StatusBar.styleDefault(); 它会将您的状态栏字体颜色更改为黑色

【讨论】:

以上是关于离子状态栏白底白字的主要内容,如果未能解决你的问题,请参考以下文章

白底黑字!Android浅色状态栏黑色字体模式(另)

离子状态栏问题 IOS

iPhone上的离子如何设置状态栏透明

android导航栏与状态栏颜色及透明度

状态栏使用 Capacitor 覆盖 iOS 上的 webview

Android修改状态栏颜色全方位教程