如何修复 Xamarin.Forms iOS 标题栏图像和标题栏背景上的颜色差异 win Android 没有这个问题

How to fix Xamarin.Forms iOS color disparity on TitleBar image VS TitleBar background when Android does not have this issue

我有一张图片(横幅大小),背景色为 #F6D401 ,需要转到顶部栏以进行品牌化。

在App.xaml我设置:

<Application.Resources>    
    <ResourceDictionary>    
        <Color x:Key="Primary">#f6d401</Color>    
        <Color x:Key="TextColor">#5a5a5a</Color> 

然后在AppShell.xaml

    <Shell.Resources>
    <ResourceDictionary>
        <Style x:Key="BaseStyle" TargetType="Element">
            <Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
            <Setter Property="Shell.ForegroundColor" Value="{StaticResource Primary}" />

然后在页面上:

    <Shell.TitleView>
    <Image
           HorizontalOptions="Center"
           VerticalOptions="Center" 
        Source="logo.png"  />
</Shell.TitleView>

在 Android 我得到一个背景横幅和所有颜色相同的颜色,这正是我想要的和预期的。

iOS,但是,颜色似乎不匹配

我假设 iOS 某处有默认设置,需要更改。

如何使横幅和图标的颜色匹配?

请将 UINavigationBar.Appearance.Translucent = false;添加到AppDelegate.cs

 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)
        {
            UINavigationBar.Appearance.Translucent = false;
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
    }

这是运行截图。