不多說(shuō)了,上代碼:
navigationBar 設(shè)置如下:
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設(shè)置如下:
if #available(iOS 15, *) {
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = k_FAFAFA
UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = UITabBar.appearance().standardAppearance
}
原文來(lái)自蘋(píng)果開(kāi)發(fā)者社區(qū):https://developer.apple.com/forums/thread/682420