2

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;
Wei Loon Wong
  • 450
  • 1
  • 7
  • 23

5 Answers5

1

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.

ColeX
  • 14,062
  • 5
  • 43
  • 240
  • May I know which version of pkg file you downloaded? Do you mind also sharing your current version of Xamarin.IOS ? – Wei Loon Wong Sep 28 '21 at 08:16
  • Xamarin.iOS 15.0.0.6 , just download the pkg file in the link and click to install on your mac. – ColeX Sep 28 '21 at 08:48
1

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.

Wei Loon Wong
  • 450
  • 1
  • 7
  • 23
1

Just fixed this issue but in Xamarin.Forms: The tabbar had a white/transparent color in iOS 15.

  1. Update VS for Mac (8.10.10 build 8).
  2. Install latest Xamarin.iOS (15.0.0.6).
  3. Use UITabBar: Add the following code somewhere in FinishedLaunching in App_Delegate.cs:
UITabBar.Appearance.BackgroundColor = Color.FromHex("333333").ToUIColor();
Vincent
  • 2,073
  • 1
  • 17
  • 24
0

Well, I think you are looking for the current ViewController's navigation item:

Try something like

        var appearance = new UINavigationBarAppearance();
        appearance.ConfigureWithOpaqueBackground();
        appearance.BackgroundColor = *Your color*;
        tabBar.NavigationItem.StandardAppearance = appearance;
        tabBar.NavigationItem.ScrollEdgeAppearance = tabBar.NavigationItem.StandardAppearance;

Where tabBar is the UITabBarController Object

Goodluck

FreakyAli
  • 13,349
  • 3
  • 23
  • 63
0

You need to use classe inherit from UIBarAppearance.

I wrote an article talking UINavigationBar on iOS 15, but I also talking about other components like UITabBar. You can check here: https://medium.com/@eduardosanti/uinavigationbar-is-black-on-ios-15-44e7852ea6f7

Eduardo Santi
  • 425
  • 1
  • 4
  • 13
  • I tried the same appearance setting for UITabBar, however, there is no reference to "scrollEdgeAppearance" in UITabBar class. I think "scrollEdgeAppearance" is necessary to resolve the issue. I'd no clue how to resolve the same problem for UITabBar without 'scrollEdgeAppearance' :( – Wei Loon Wong Sep 28 '21 at 04:59
  • Apple introduced the scrollEdgeAppearance in iOS 15 for TabBar too. Something like UITabBar().scrollEdgeAppearance – Eduardo Santi Sep 28 '21 at 09:43