Kushal Mukherjee
Kushal Mukherjee

Reputation: 363

Unable to change the Navigation bar tint color for large titles in iOS 13

Code:

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        UINavigationBar.appearance().barTintColor = .red

        return true
    }

if prefersLargetitles is false then there is no problem. But with prefersLargeTitles = true, the color doesn't change. This used to work with iOS 12. But since iOS 13 this is not working. Can anybody help on how to customise navigation bars in iOS 13

Upvotes: 3

Views: 435

Answers (1)

Ankit Jayaswal
Ankit Jayaswal

Reputation: 5679

There are some changes regarding navigation bar appearance in iOS 13, by default navigation bar becomes transparent if associates view controller has scrollable content.

In this case, you should create an UINavigationBarAppearance object and assign it to compactAppearance and scrollEdgeAppearance. You can change properties of UINavigationBarAppearance object as well.

if #available(iOS 13.0, *) {
    let appearance = UINavigationBarAppearance()
    appearance.backgroundColor = .purple
    UINavigationBar.appearance().compactAppearance = appearance
    UINavigationBar.appearance().scrollEdgeAppearance = appearance
} else {
    UINavigationBar.appearance().barTintColor = .purple
}

You can find more detail at here & iOS13release_notes

Upvotes: 8

Related Questions