Xamarin Forms iOS 状态栏文本颜色 [英] Xamarin Forms iOS status bar text color

查看:24
本文介绍了Xamarin Forms iOS 状态栏文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将我的 Xamarin Forms iOS 应用的状态栏文本颜色更改为白色.我的 info.plist 有如下变化:

I am unable to change the status bar text color of my Xamarin Forms iOS app to white. I have change in my info.plist as follow:

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

但颜色仍然保持黑色..还有其他方法可以更改状态栏文本颜色吗?

Yet the color still remain black.. Is there another way to change the status bar text color?

推荐答案

在 Xamarin.Forms 中,需要执行三件事才能在 iOS 状态栏中实现白色文本.我还在下面发布了一个示例 Xamarin.Forms 应用程序,它在 iOS 状态栏中使用白色文本.

In Xamarin.Forms, there are three things you need to do to achieve white text in the iOS Status Bar. I've also posted a sample Xamarin.Forms app below that uses white text in the iOS Status Bar.

Info.plist中,添加布尔属性View controller-based status bar appearance并将其值设置为No

In Info.plist, add the Boolean Property View controller-based status bar appearance and set its value to No

Application 类(通常是App.cs)中,MainPage 必须是一个NavigationPage,并且BarTextColor 必须设置为 Color.White

In the Application class (typically App.cs), the MainPage must be a NavigationPage, and the BarTextColor must be set to Color.White

有时编译器在您清理和重建应用程序之前不会更新状态栏颜色,因此在步骤 1 和 1 中进行更改后,2、清理应用程序并重建它.

Sometimes the compiler doesn't update the Status Bar Color until you Clean and Rebuild the app, so after making the changes in steps 1 & 2, clean the app and rebuild it.

https://github.com/brminnick/SaveImageToDatabaseSampleApp/

这篇关于Xamarin Forms iOS 状态栏文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆