Reputation: 3358
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.
Upvotes: 4
Views: 3224
Reputation: 1601
Android
Build.VERSION_CODES.Lollipop
is obsolete. Use Android.OS.BuildVersionCodes
:
if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
Window.SetStatusBarColor(Android.Graphics.Color.Orange;
Window.SetNavigationBarColor(Android.Graphics.Color.Orange;
}
Upvotes: 1
Reputation: 12723
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);
}
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
After click button, changed dynamically to green color.
Upvotes: 8