uwp开发,手机状态栏怎么显示

发布网友

我来回答

1个回答

热心网友

  1、项目引用里面增加移动设备的扩展API
  在“Solution Explorer”里面,右键点“References”,弹出菜单里面选“Add References ...”,左侧列表里面选“Universal Windows”、选“Extensions”,右侧列表里面选中“Windows Mobile Extensions for the UWP”,点右下“OK”按钮
  2、代码里面判断如果存在StatusBar的类(移动设备上运行时会存在),利用这个类显示状态栏
public MainPage()
{
InitializeComponent();
ShowStatusBar();
}
   private async void ShowStatusBar()
{
if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
{
var statusbar = StatusBar.GetForCurrentView();
await statusbar.ShowAsync();
statusbar.BackgroundColor = Colors.White;
statusbar.BackgroundOpacity = 1;
statusbar.ForegroundColor = Colors.Black;
}
}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com