我正在按照 ionic 2 文档设置 iOS 状态栏颜色,但它不起作用.状态栏文本是白色的,这意味着在我的白色背景上它是不可见的.
我在应用构造函数中的代码是:
StatusBar.overlaysWebView(true);StatusBar.styleDefault();我已经使用以下方法导入了 StatusBar:
import {StatusBar} from 'ionic-native';我还检查了 Cordova 状态栏插件是否已安装.
你可以尝试这样在config.xml中添加这个,你要设置的颜色的十六进制值:
对于 ngCordova 或 ionic-native,您可以使用
$cordovaStatusbar.styleColor('black');$cordovaStatusbar.styleHex('#000');<小时>
或者你在状态栏cordova插件github页面上查看有一些方法可以改变状态栏的颜色:https://github.com/apache/cordova-plugin-statusbar
对于 Android:
if (cordova.platformId == 'android') {StatusBar.backgroundColorByHexString("#333");}适用于 iOS
在 iOS 7 上,当你将 StatusBar.statusBarOverlaysWebView 设置为 false 时,你可以通过颜色名称来设置状态栏的背景颜色.
StatusBar.backgroundColorByName("red");支持的颜色名称有:
黑色、深灰色、浅灰色、白色、灰色、红色、绿色、蓝色、青色、黄色、洋红色、橙色、紫色、棕色或者
通过十六进制字符串设置状态栏的背景颜色.
StatusBar.backgroundColorByHexString("#C0C0C0");还支持 CSS 速记属性.
StatusBar.backgroundColorByHexString("#333");//=>#333333StatusBar.backgroundColorByHexString("#FAB");//=>#FFAABB在 iOS 7 上,当您将 StatusBar.statusBarOverlaysWebView 设置为 false 时,您可以通过十六进制字符串 (#RRGGBB) 设置状态栏的背景颜色.在 WP7 和 WP8 上,您还可以将值指定为 #AARRGGBB,其中 AA 是 alpha 值
I am following the ionic 2 documentation for setting the iOS status bar color but it is not working. The status bar text is white which means on my white background it is invisible.
The code I have put in my app constructor is:
StatusBar.overlaysWebView(true);
StatusBar.styleDefault();
I have imported StatusBar using:
import {StatusBar} from 'ionic-native';
I have also checked that the cordova statusbar plugin is installed.
You can try like this add this in the config.xml, with the hex value of the color you want to set:
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#000000" />
For ngCordova or ionic-native you can use
$cordovaStatusbar.styleColor('black');
$cordovaStatusbar.styleHex('#000');
Or you check on the statusbar cordova plugin github page there are some ways to change the color of status bar: https://github.com/apache/cordova-plugin-statusbar
For Android:
if (cordova.platformId == 'android') {
StatusBar.backgroundColorByHexString("#333");
}
For iOS
On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false, you can set the background color of the statusbar by color name.
StatusBar.backgroundColorByName("red");
Supported color names are:
black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown
Or
Sets the background color of the statusbar by a hex string.
StatusBar.backgroundColorByHexString("#C0C0C0");
CSS shorthand properties are also supported.
StatusBar.backgroundColorByHexString("#333"); // => #333333
StatusBar.backgroundColorByHexString("#FAB"); // => #FFAABB
On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false, you can set the background color of the statusbar by a hex string (#RRGGBB).
On WP7 and WP8 you can also specify values as #AARRGGBB, where AA is an alpha value
这篇关于在 ionic 2 应用程序中更改 iOS 状态栏颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
出现键盘时如何在iOS上调整UITextView的大小?How to resize UITextView on iOS when a keyboard appears?(出现键盘时如何在iOS上调整UITextView的大小?)
如何可靠地检测 iOS 9 上是否连接了外部键盘?How to reliably detect if an external keyboard is connected on iOS 9?(如何可靠地检测 iOS 9 上是否连接了外部键盘?)
如何在 iOS 7 上模拟键盘动画以添加“完成"数How to mimic Keyboard animation on iOS 7 to add quot;Donequot; button to numeric keyboard?(如何在 iOS 7 上模拟键盘动画以添加“完成数字键
如何关闭 iOS 键盘?How do I dismiss the iOS keyboard?(如何关闭 iOS 键盘?)
是否可以在 ios 越狱后使用外部键盘模拟触摸事件Is possible to simulate touch event using an external keyboard on ios jailbroken?(是否可以在 ios 越狱后使用外部键盘模拟触摸事件?)
如何从 iOS 应用程序上的自定义键盘检索击键?How do I retrieve keystrokes from a custom keyboard on an iOS app?(如何从 iOS 应用程序上的自定义键盘检索击键?)