2016-12-29 24 views
1

我读过不同的文章,它的工作,但不知何故它不适合我。 我加入的plistXamarin表单NavigationPage.BarTextColor不起作用

<key>UIViewControllerBasedStatusBarAppearance</key> 
    <false/> 

而且

var p = new FreshNavigationContainer(page); 
    p.BarTextColor = Color.Fuchsia; 
    p.BarBackgroundColor = Color.Aqua; 
    MainPage = p; 

FreshNavigationContainer从NavigationPage的。

我想有能力更改每个页面上的状态栏颜色。当页面很暗时 - 我需要状态栏才能亮起。反之亦然。

+0

嗨Vorotnyak!这个问题只发生在iOS?你能否确认它是否也在Android应用上发生? –

+0

我已经留下了一些基于你所期望的猜测的答案。如果你可以用更具体的问题来更新问题,那么你可以根据需要调整我的答案。 – therealjohn

+0

你可以分享FreshNavigationContainer代码吗? – Atul

回答

2

我认为你确实想要改变颜色有些混淆。

UIViewControllerBasedStatusBarAppearance通常与更改状态栏文字颜色结合使用。例如,

UIApplication.SharedApplication.SetStatusBarStyle (UIStatusBarStyle.LightContent, false); 

这将使这样的变化:

enter image description here

看起来你可能期待BarTextColor改变这一点。但是,这改变了上图中的文字“我的费用”。

您必须使用iOS API(不是表单)更改iOS项​​目中的状态栏文字颜色。样品here。如果你想你的整个应用都在状态栏中浅文本颜色,更新您的info.plist到:

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

更新:

如果你想改变每个页面的状态栏的颜色,您需要将UIViewControllerBasedStatusBarAppearance设置为true。然后,您需要在iOS项目中为每个要更改状态栏颜色的页面使用PageRenderer。在渲染器中,您可以在ViewWillAppear方法中调用UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;

请记住,您在款式上的选项有限,列出了here

+0

我想有能力分别更改每个页面上的状态栏颜色。我该怎么做? 上面的代码改变了整个应用的状态栏颜色 –

+0

我已经更新了我的答案以解决这个问题 – therealjohn