iOS15 UINavigationBar、UITabBar

不多说了,上代码:
navigationBar 设置如下:

if #available(iOS 15, *) {
     let appearance = UINavigationBarAppearance()
     appearance.configureWithOpaqueBackground()
     appearance.backgroundImage = UIImage(named: "navigation-back-img")
     appearance.shadowImage = UIImage()
     appearance.shadowColor = UIColor.clear
     appearance.titleTextAttributes = [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 18),NSAttributedString.Key.foregroundColor:k_FFFFFF]
     navigationBar.standardAppearance = appearance
     navigationBar.scrollEdgeAppearance = navigationBar.standardAppearance
}

UITabBar设置如下:

if #available(iOS 15, *) {
     let appearance = UITabBarAppearance()
     appearance.configureWithOpaqueBackground()
     appearance.backgroundColor = k_FAFAFA
     UITabBar.appearance().standardAppearance = appearance
     UITabBar.appearance().scrollEdgeAppearance = UITabBar.appearance().standardAppearance
}

原文来自苹果开发者社区:https://developer.apple.com/forums/thread/682420

你可能感兴趣的:(iOS15 UINavigationBar、UITabBar)