LoginSignup
2
3

More than 1 year has passed since last update.

ios15の場合、デフォルトでは、tableviewとnavigation barが透過されてしまう

Last updated at Posted at 2021-12-13

[SwiftUI] iOS15の場合、デフォルトでは、tableviewとnavigation barが透過されてしまう
ので、それを防ぐ

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // TabViewの背景色の設定
        UITabBar.appearance().backgroundColor = UIColor.white

        // NavigationBarの背景色の設定
        let appearance = UINavigationBarAppearance()
        appearance.configureWithOpaqueBackground()
        appearance.backgroundColor = UIColor.white
        UINavigationBar.appearance().standardAppearance = appearance
        if #available(iOS 15.0, *) {
            UINavigationBar.appearance().scrollEdgeAppearance = appearance
        }
        return true
    }
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3