With iOS 15, Apple has extended support for scrollEdgeAppearance to UIKit.
This setting produces a transparent TabBar background by default.
To fix the issue add the code below to your SceneDelegate file, to define the color of your TabBar, so it isn't made transparent automatically by SwiftUI.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
guard let windowScene = (scene as? UIWindowScene) else { return }
// MARK: ADD THIS CODE BELOW TO YOUR SCENE DELEGATE.
// TAB BAR BACKGROUND COLOR HERE.
UITabBar.appearance().barTintColor = UIColor.white
// TAB BAR ICONS COLOR HERE.
UITabBar.appearance().tintColor = UIColor.blue
UITabBar.appearance().isTranslucent = true
if #available(iOS 15.0, *) {
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
// TAB BAR BACKGROUND COLOR HERE. (same as above)
appearance.backgroundColor = UIColor.white
UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = UITabBar.appearance().standardAppearance
}
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: RootView())
self.window = window
window.makeKeyAndVisible()
}
}