gpt4 book ai didi

c# - 在 Xamarin.Forms 应用程序中更改顶部和底部栏(ControlsBar、StatusBar)的颜色

转载 作者:行者123 更新时间:2023-11-30 21:29:04 24 4
gpt4 key购买 nike

无论如何,即使需要平台特定的代码,也可以更改顶部栏(蓝色的)和底部栏(黑色的)的颜色吗?

我希望添加对明暗模式的支持,因此我希望能够在运行时更改它。

Android

最佳答案

有可能

安卓:

使用 Window.SetStatusBarColorWindow.SetNavigationBarColor 可以在 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:

在ios中,改变导航栏和状态栏,可以如下使用:

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

enter image description here

点击按钮后,动态变为绿色。

enter image description here

关于c# - 在 Xamarin.Forms 应用程序中更改顶部和底部栏(ControlsBar、StatusBar)的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55750781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com