Rajzer
Rajzer

Reputation: 1296

Xamarin Forms where to change StatusBar For Android and IOS

enter image description here

I'm using Xamarin.Forms and want to Navigation in all pages to have #84DCC6. It adds but i dont want to have the blue color on top (which is default in Android project )of The navigation page, i want to have just one color #84DCC6. This is my code in App.xaml


<Application.Resources>
        <ResourceDictionary>

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

I'm testing my App on Xiaomi A2 Lite. Any suggesstions to be just one color #84DCC6

Upvotes: 0

Views: 659

Answers (1)

MShah
MShah

Reputation: 1267

The blue color you are talking about is not a navigation bar, its a status bar.

Android:

you can change its color from Styles.xml file situated under your android project Resource folder:

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

iOS

use this below code inside your app delegate class

var statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
            if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
            {
                statusBar.BackgroundColor = UIColor.FromRGB(132, 220, 198);
                statusBar.TintColor = UIColor.Black;
            }

Upvotes: 2

Related Questions