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:
- use only one root
NavigationView
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)
}
}
}
- Create custom tab bar (using
HStack
ofButton
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
Adding Constraints Programmatically in UIview with UItextview
Problems with Unified Logging, Staticstring, Customstringconvertible and Description
Using Nsdate to Get Date for Easter
Tintcolor Not Changing for UIbarbuttonitem for .Normal Stage in Case of iOS 13.2
Compiler Segmentation Fault While Using Set in Swift
Access Each Header and Controls in The Tableview in Swift
How to Get Unsaferawpointer on The Swift Object
Aws Cognito Credentialsprovider.Login Always Shows Nil (Swift)
Could Not Find Member <Method Name> for Struct Type in Swift
Writing an Enum Case Check to a Bool Variable Without Equatable Conformance
#If Canimport(Coreimage) Not Working in Swift Package Manager
How to Increment a Swift Int Enumeration
Print Not Working in Swift 3 Extensions
Cannot Authenticate User for Aws Appsync with Swift Sdk
Expressions Are Not Allowed at The Top Level
Os X App Doesn't Launch New Window on Dock Icon Press in Swift