Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the color of the top and bottom bar (ControlsBar, StatusBar) in a Xamarin.Forms app

Is there anyway, even if requires platform specific code behind, to change the color of both the top bar (the one in blue) and the bottom bar (the one in black)?

I wish to add support for light and dark modes, so I would like to be able to change that during runtime.

Android

like image 648
Nicke Manarin Avatar asked Jan 27 '23 10:01

Nicke Manarin


1 Answers

It is possible .

Android:

Using Window.SetStatusBarColor and Window.SetNavigationBarColor can do that easily above Android API 21.

  if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Lollipop)
  {
       Window.SetStatusBarColor(Android.Graphics.Color.Orange);
       Window.SetNavigationBarColor(Android.Graphics.Color.Orange);
   }

enter image description here

IOS:

In ios, change navigation bar and status bar , can use as bellow:

NavigationController.NavigationBar.BarTintColor = UIColor.YouWantColor;
// Color you want, such as UIColor.Green

enter image description here

After click button, changed dynamically to green color.

enter image description here

like image 133
Junior Jiang Avatar answered Jan 30 '23 13:01

Junior Jiang