Search code examples
xamarin.iosios15bartintcolor

UITabBarController BarTintColor not working in iOS15


In iOS15, I came across an issue that the bottom bar's color not showing a correct color and it changed into transparent/white. The same code works good in iOS14 & iOS13.

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.

Based on this issue, I assuming I need to convert the code from UINavigationBar to UITabBar. However, I don't see any reference to "scrollEdgeAppearance" in UITabBar class. I believe this is important to fix the issue. I'd be grateful if someone can give me some advice. Many Thanks.

Code to change Tab bar color that works in iOS14 & iOS13

TabBar.BarTintColor = UIColor.Blue;

UINavigationBar

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

my own UITabBar code

     var appearance = new UITabBarAppearance();
     appearance.ConfigureWithOpaqueBackground();
     appearance.BackgroundColor = UIColor.Blue;
     this.TabBarController.TabBar.StandardAppearance = appearance;

Solution

  • Visual Studio for Mac now includes Xamarin.iOS 15.0.0.6 updates.

    I updated Visual Studio for Mac to Version 8.10.9 (build 3) and Xamarin.iOS to 15.0.0.6

    I resolved the UITabBar bar color with following code:

    var appearance = new UITabBarAppearance();
    appearance.ConfigureWithOpaqueBackground();
    appearance.BackgroundColor = UIColor.Blue; // color you want
    
    TabBar.StandardAppearance   = appearance;
    TabBar.ScrollEdgeAppearance = TabBar.StandardAppearance;
    

    *** As on date of 30 Sept, you might still see no reference to "scrollEdgeAppearance" in UITabBar class if you're using Visual Studio for Windows. You can ignore it because you can still build the project without errors.