无法更改iOS 13中大标题的导航栏色调颜色

问题描述 投票:1回答:1

代码:

 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 {//自定义覆盖点...

ios swift ios13
1个回答
0
投票
if #available(iOS 13.0, *) {
    let appearance = UINavigationBarAppearance()
    appearance.backgroundColor = .purple
    UINavigationBar.appearance().compactAppearance = appearance
    UINavigationBar.appearance().scrollEdgeAppearance = appearance
} else {
    UINavigationBar.appearance().barTintColor = .purple
}
© www.soinside.com 2019 - 2024. All rights reserved.