초림이의 연구실

[Swift] Xcode 13 UINavigationBar and UITabBar appearance bug

Declare private methods

// MARK: - Private Methods
 extension AppDelegate {
   func setupNavigationAppearance() {
     let appearance = UINavigationBarAppearance()
     let navigationBar = UINavigationBar()
     appearance.configureWithOpaqueBackground()
     appearance.backgroundColor = UIColor.white
     navigationBar.standardAppearance = appearance
     UINavigationBar.appearance().scrollEdgeAppearance = appearance
   }
   func setupTabBarAppearance() {
     let appearance = UITabBarAppearance()
     let tabBar = UITabBar()
     appearance.configureWithOpaqueBackground()
     appearance.backgroundColor = .white
     tabBar.standardAppearance = appearance
     if #available(iOS 15.0, *) {
       UITabBar.appearance().scrollEdgeAppearance = appearance
     }
   }
 }

Call a private methods in AppDelegate or SceneDelegate

setupNavigationAppearance()
setupTabBarAppearance()

Exit mobile version