Xamarin iOS: UITabBarController BarTintColor not working in iOS 15

Wong Wei Loon 11 Reputation points
2021-09-23T17:01:30.66+00:00

I came across a similar issue in this post.

I have a tab bar renderer class for iOS, in ViewWillAppear(), I use code TabBar.BarTintColor = UIColor.Blue to change tab bar color, it works only for iOS below than iOS15 but not in iOS15.

I tried to convert UINavigationBar ( iOS code ) into UITabBar (Xamarin.iOS C#).

iOS Native Code:

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

my own code for Xamarin.iOS C#

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

However, there is no reference to "scrollEdgeAppearance" in UITabBar class Xamarin.iOS C#, and it seems important to add this to solve the issue. I'd be grateful if someone can give me some advice or point out my mistakes.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,366 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alberto A 6 Reputation points
    2021-10-01T20:52:50.287+00:00

    I added only this line and it fixed it
    public override bool FinishedLaunching(UIApplication app, NSDictionary options){
    UITabBar.Appearance.BackgroundColor = UIColor.Black;}

    That fixed it and looks like it used to look <15

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.