Xamarin在哪里更改Android和IOS的StatusBar的位置

问题描述 投票:0回答:1

enter image description here

我正在使用Xamarin.Forms,并且希望在所有页面中导航以具有#84DCC6。它添加了但我不希望导航页面的顶部具有蓝色(这是Android项目中的默认设置),我只希望具有#84DCC6一种颜色。这是我在App.xaml中的代码


<Application.Resources>
        <ResourceDictionary>

        <Style TargetType="NavigationPage">
            <Setter Property="BarBackgroundColor" Value="#84DCC6" />
            <Setter Property="BarTextColor" Value="Black" />
        </Style>
        </ResourceDictionary>
    </Application.Resources>

我正在小米A2 Lite上测试我的App。任何建议只能是一种颜色#84DCC6

xamarin.forms xamarin.android xamarin.ios
1个回答
0
投票

您正在谈论的蓝色不是导航栏,而是状态栏。

Android:

您可以从位于Android项目Resource folder下的Styles.xml文件中更改其颜色:>

<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1eb6ed</item>

iOS

在应用程序委托类中使用下面的代码

 UIView statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
    if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
    {
        statusBar.BackgroundColor = color.ToUIColor();
    }
© www.soinside.com 2019 - 2024. All rights reserved.