代码:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UINavigationBar.appearance().barTintColor = .red
return true
}
如果prefersLargetitles为false,则没有问题。但是,随着preferredsLargeTitles = true的出现,颜色不会改变。该功能过去曾在iOS 12上运行。但是,由于iOS 13不能正常运行。有人可以帮忙在iOS 13中自定义导航栏吗?
代码:func应用程序(_应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey:任何]?)-> Bool {//自定义覆盖点...
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = .purple
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
} else {
UINavigationBar.appearance().barTintColor = .purple
}