有人知道如何在JavaScript的Windows Phone 8.1应用程序中启用状态栏(如图片所示)吗?我正在使用Visual Studio 2013带有Update 2的JavaScript Pivot模板。
有人知道如何在JavaScript的Windows Phone 8.1应用程序中启用状态栏(如图片所示)吗?我正在使用Visual Studio 2013带有Update 2的JavaScript Pivot模板。
例如,您需要在页面的ready函数中添加一些JavaScript代码。
首先获取当前视图的状态栏。然后决定该如何处理:
var s = Windows.UI.ViewManagement.StatusBar.getForCurrentView();
s.showAsync(); // shows the statusbar
可在MSDN了解有关状态栏的更多信息。
var s = Windows.UI.ViewManagement.StatusBar.getForCurrentView();
s.showAsync();
// THIS IS WRONG
s.backgroundColor = 'red';
s.backgroundColor = '#A65959';
这样做是不行的,会抛出错误:
0x800a13ec - JavaScript运行时错误:无法将对象转换为结构:缺少预期属性'a'的对象
这是因为s.backgroundColor不是HTML对象,而是WinRT运行时对象,因此我们需要使用WinRT的“Color”结构体,这与HTML/JS颜色概念几乎没有关系。
但首先让我们先修复透明度(不透明度)。默认情况下,条形图的背景层完全透明。将其不透明度设置为1.0即可使其完全不透明。
简而言之;
// THIS IS RIGHT
s.backgroundOpacity = 0.99;
s.backgroundColor = Windows.UI.ColorHelper.fromArgb(255, 0xA6, 0x59, 0x59);
s.foregroundColor = Windows.UI.Colors.lightGray;
>:o
在Windows.UI.Colors
中有一堆预定义的颜色常量,但要注意驼峰命名(例如lightGray
),这与HTML / JS颜色命名约定不同。