xamarin.forms - Xamarin Forms Shell 标题栏颜色在深色主题中未正确设置
问题描述
我有一个 xamarin 表单 shell 应用程序。我用这种风格设置标题栏颜色:
<Color x:Key="BackgroundColorDark">#121212</Color>
<Color x:Key="BackgroundColorLight">#EFF2F5</Color>
<Color x:Key="TextPrimaryColor_Dark">#FFFFFF</Color>
<Color x:Key="TextPrimaryColor_Light">#323130</Color>
<Style x:Key="BaseStyle"
TargetType="Element"
ApplyToDerivedTypes="True">
<Setter Property="Shell.BackgroundColor"
Value="{AppThemeBinding Dark={StaticResource BackgroundColorDark}, Light={StaticResource BackgroundColorLight}}" />
<Setter Property="Shell.ForegroundColor"
Value="{AppThemeBinding Dark={StaticResource TextPrimaryColor_Dark}, Light={StaticResource TextPrimaryColor_Light}}" />
<Setter Property="Shell.DisabledColor"
Value="#B4000000" />
<Setter Property="Shell.UnselectedColor"
Value="#CC0000" />
<Setter Property="Shell.NavBarHasShadow"
Value="false"/>
</Style>
在浅色主题中,这可以按预期工作,并且与背景相同:
因为它看起来好像标题栏是半透明的,所以我尝试使用导航页面上的 ios 特定设置显式停用它,但这不起作用。
ios:NavigationPage.IsNavigationBarTranslucent="true"
如何正确应用深色主题中的背景颜色?
Xamarin 表单版本:4.8.0.1269 源代码存储库:https ://github.com/NPadrutt/MoneyFox.Windows/tree/mobile-redesign
解决方案
在iOS.project中,您可以设置删除默认 alphaUINavigationBar.Appearance.Translucent = false;
的 方法。FinishedLaunching
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental");
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
UINavigationBar.Appearance.Translucent = false;
return base.FinishedLaunching(app, options);
}
}
推荐阅读
- c# - 自动保存文件而不提示在网络浏览器中保存文件
- javascript - 连接到服务器的 NODE JS Socket.io 错误
- python - Pandas 通过拆分可选的前导非字符串字符来计算新列
- python - 如何使用 Python PIL 粘贴到特定位置?
- java - 如何在另一个路径中加载 application.properties 文件?
- visual-c++ - 如何在 C++/CPLEX 中集成回调的输出
- python - Pandas 将时间范围转换为索引
- scala - 如何获取A列中不在Apache Spark数据框B列中的元素列表?
- node.js - 不从自定义助手返回值
- ios - 无法获取子集合数据