Non-Translucent UItabbar Creates Strange Grey Bar

Non-translucent UITabBar creates strange grey bar

This

        UITabBar.appearance().isTranslucent = false

is a hack (non-documented assumption about TabView internal implementation) that breaks NavigationView layout (removes view to which NavigationView has active constraints)

Here are possible workarounds:

  1. use only one root NavigationView

demo

struct ContentView: View {

init() {

UITabBar.appearance().backgroundColor = UIColor.white
UITabBar.appearance().isTranslucent = false
}

@State private var title = ""
var body: some View {

NavigationView {
TabView {

Text("First tab")
.padding(10)
.background(Color.white)
.onAppear {
self.title = "First tab"
}
.tabItem {
Text("First tab")
}

Text("Second tab")
.padding(10)
.background(Color.white)
.onAppear {
self.title = "Second tab"
}
.tabItem {
Text("Second tab")
}
}
.navigationBarTitle(Text(title), displayMode: .inline)
}
}
}

  1. Create custom tab bar (using HStack of Button views)

UISplitView with UITabbar

I subclassed UISplitViewController and added the line below to viewDidLoad and that fixed the grey line.

self.extendedLayoutIncludesOpaqueBars = YES;

UITabBarItem icon not colored correctly for iOS 13 when a bar tint color is specified in Interface Builder in Xcode 11, beta 2

On the surface, this might seem like a bug, however you can mitigate it by defining an .unselectedItemTintColor on your UITabBar instance.

self.tabBar.unselectedItemTintColor = [UIColor lightGrayColor];

Remove UITabbar upper border line

[self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"];

or you can use

[[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"transparentShadow.png"]];

or

 [[UITabBar appearance] setShadowImage:nil];

UITabBarItem badge colour is showing grey

It was my mistake, I had set the Tab bar item Badge colour specifically to grey in the storyboard.



Related Topics



Leave a reply



Submit