【问题标题】:Xamarin iOS: BarTintColor not working in iOS 15Xamarin iOS:BarTintColor 在 iOS 15 中不起作用
【发布时间】:2021-11-17 02:11:08
【问题描述】:

我在post 中遇到了类似的问题。

我尝试将 iOS 本机代码转换为 Xamarin.iOS C#。

iOS 原生代码:

let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = <your tint color>
navigationBar.standardAppearance = appearance;
navigationBar.scrollEdgeAppearance = navigationBar.standardAppearance

我自己的 Xamarin.iOS C# 代码

if (UIDevice.CurrentDevice.CheckSystemVersion(15, 0))
{
    var appearance = new UITabBarAppearance();
    appearance.ConfigureWithOpaqueBackground();
    appearance.BackgroundColor = UIColor.FromRGB((float)rgbColorBackground.R, (float)rgbColorBackground.G, (float)rgbColorBackground.B);
    this.TabBarController.TabBar.StandardAppearance = appearance;
}
else
     TabBar.BarTintColor = UIColor.FromRGB((float)rgbColorBackground.R, (float)rgbColorBackground.G, (float)rgbColorBackground.B);

但是,在 Xamarin.iOS C# 中没有对“scrollEdgeAppearance”的引用,添加它来解决问题似乎很重要。如果有人能给我一些建议或指出我的错误,我将不胜感激。

【问题讨论】:

  • 我建议您暂时切换版本(12 或 13)并报告问题。

标签: xamarin.ios ios15 bartintcolor


【解决方案1】:

我这样做是为了解决 IOS 15 中的透明标签栏问题。

public override bool FinishedLaunching(UIApplication app, NSDictionary options)

// 选中标签图标的颜色: UITabBar.Appearance.SelectedImageTintColor = AppColors.Primary500Color.ToUIColor(); UITabBar.Appearance.BackgroundColor = AppColors.WhiteColor.ToUIColor(); if (UIDevice.CurrentDevice.CheckSystemVersion(15, 0)) UITabBar.Appearance.ScrollEdgeAppearance = new UITabBar().StandardAppearance;

问候乔西姆

【讨论】:

    猜你喜欢
    • 2021-10-27
    • 2020-03-24
    • 2021-08-29
    • 2021-12-05
    • 2020-10-20
    • 1970-01-01
    • 2022-10-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多