繁体   English   中英

在Visual Studio 2013的Windows Phone javascript模板中启用状态栏

[英]Enable the status bar in the Windows Phone javascript templates for Visual Studio 2013

有谁知道如何在JavaScript Windows Phone 8.1应用程序中启用状态栏(图片)? 我在Visual Studio 2013中使用更新2的javascript数据透视表模板。

在此输入图像描述

例如,您必须在页面的ready函数中添加一些JavaScript。

首先获取当前视图的状态栏。 而不是决定如何处理它:

var s = Windows.UI.ViewManagement.StatusBar.getForCurrentView();
s.showAsync(); // shows the statusbar

有关状态栏的更多信息,请访问MSDN

@Sorskoot的回答给了我很多帮助,但我只花了一个小时的时间来寻找如何改变状态栏的背景颜色 所以我将分享(作为启用状态栏并设置它的颜色通常一起):

下面的代码显示了状态栏(或者名称建议向消息队列提交请求以执行此操作)

var s = Windows.UI.ViewManagement.StatusBar.getForCurrentView();
s.showAsync(); 

如果您尝试设置这样的颜色

// THIS IS WRONG
s.backgroundColor = 'red';
s.backgroundColor = '#A65959';

这将0x800a13ec - JavaScript runtime error: Could not convert object to struct: object missing expected property 'a'正常工作,抛出错误: 0x800a13ec - JavaScript runtime error: Could not convert object to struct: object missing expected property 'a'

这是因为s.backgroundColor不是HTML对象,而是WinRT运行时对象,因此我们需要使用WinRT的“Color”结构,这与HTML / JS颜色概念没什么关系。

但首先让我们先修复透明度(不透明度)。 默认情况下,条形图的bg图层是完全透明的。 将其不透明度设置为1.0,使其完全不透明。

TL; DR;

// THIS IS RIGHT
s.backgroundOpacity = 0.99; 
s.backgroundColor = Windows.UI.ColorHelper.fromArgb(255, 0xA6, 0x59, 0x59);
s.foregroundColor = Windows.UI.Colors.lightGray;

上面我们使用helper类来构建WinRT Color结构。 请注意,在帮助器参数中,不透明度在0-255范围内。 但是在s.backgroundOpacity中,它在范围[0..1] >:o浮动

Windows.UI.Colors有一堆预定义的颜色常量,但请注意camelCasing (例如lightGray ),它与HTML / JS颜色命名约定不同)

暂无
暂无

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

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