简体   繁体   English

Xamarin.iOS没有导航栏时如何更改状态栏的颜色

[英]Xamarin.iOS how do I change the status status bar color when there is no Navigation bar

When using using a NavigationBar I could write 当使用导航栏时,我可以写

this.NavigationController.NavigationBar.BarTintColor = Constants.PrimaryColor;
this.NavigationController.NavigationBar.Translucent = false;

But I want something like this only a particular ViewController which has no NavigationBar. 但是我只想要一个没有NavigationBar的特定ViewController。

在此处输入图片说明

How can I achieve this? 我该如何实现?

You can do this: 你可以这样做:

        NavigationController.NavigationBar.BackgroundColor = UIColor.Orange;
        NavigationController.NavigationBar.BarTintColor = UIColor.Orange;
        var attr = new UIStringAttributes();
        attr.ForegroundColor = UIColor.White;
        NavigationController.NavigationBar.TitleTextAttributes = attr;
        NavigationController.NavigationBar.Translucent = false;
        NavigationController.NavigationBar.BarStyle = UIBarStyle.Black;

The last line will do the trick... 最后一行可以解决问题...

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

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