Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
like image 775
Wei Loon Wong Avatar asked Dec 06 '25 04:12

Wei Loon Wong


2 Answers

Have you ever checked this link:https://github.com/xamarin/xamarin-macios/issues/12778 ?

Since currently there is no update for iOS 15 in visual studio so we need to download the pkg file and install Xamarin.iOS manually to test iOS 15.

I download and install it , use the following code , everything works fine .

if(UIDevice.CurrentDevice.CheckSystemVersion(15,0))
{

   var appearance = new UITabBarAppearance();
   appearance.ConfigureWithOpaqueBackground();
   appearance.BackgroundColor = UIColor.Blue;

   tab.TabBar.StandardAppearance = appearance;
   tab.TabBar.ScrollEdgeAppearance = tab.TabBar.StandardAppearance;
}

enter image description here

Refer to

https://stackoverflow.com/a/68749895/8187800.

like image 137
ColeX - MSFT Avatar answered Dec 09 '25 16:12

ColeX - MSFT


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.

like image 32
Wei Loon Wong Avatar answered Dec 09 '25 15:12

Wei Loon Wong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!