iOS15 Xcode 13 Global Accent Color not working

Viewed 1691

I'm using the latest beta of Xcode 13 with an app for iOS 14 and now I'm facing this strange issue: The global accent color of my app was working fine until the iOS 15 update when the color is now set as the default blue where before it was my custom color.

Here is the asset catalog:
enter image description here

This is my project settings page where you can see that the accent color is correct.
enter image description here

And this is what the app looks like when built. The color is the default blue when it needs to be a really dark blue/purple color.
enter image description here

2 Answers

We were using the UIAppearance API in our app. We were not setting the tint color, but somehow calling any of the UIAppearance API's after the app has finished launching causes this behavior.

enum AppAppearance {
    static func configure() {
        configureCustomBarApperance()
        UITableView.appearance().backgroundColor = UIColor(named: .primaryBackground)
        UITextView.appearance().backgroundColor = nil
        UIScrollView.appearance().keyboardDismissMode = .interactive
    }

    static func configureCustomBarApperance() {
        let barAppearance = UIBarAppearance()
        barAppearance.configureWithTransparentBackground()
        barAppearance.backgroundColor = UIColor(named: .primaryBackground)
        // Toolbars
        let toolbarAppearance = UIToolbarAppearance(barAppearance: barAppearance)
        UIToolbar.appearance().standardAppearance = toolbarAppearance
        UIToolbar.appearance().compactAppearance = toolbarAppearance
        UIToolbar.appearance().scrollEdgeAppearance = toolbarAppearance
        // Navigation Bars
        let navBarAppearance = UINavigationBarAppearance(barAppearance: barAppearance)
        navBarAppearance.titleTextAttributes[.foregroundColor] = UIColor.secondaryLabel
        UINavigationBar.appearance().standardAppearance = navBarAppearance
        UINavigationBar.appearance().compactAppearance = navBarAppearance
        UINavigationBar.appearance().scrollEdgeAppearance = navBarAppearance
        // Tab Bars
        let tabBarAppearance = UITabBarAppearance()
        tabBarAppearance.configureWithTransparentBackground()
        tabBarAppearance.backgroundColor = UIColor(named: .secondaryBackground)
        UITabBar.appearance().standardAppearance = tabBarAppearance
        UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
    }
}

Our solution was to move all of the UIAppearance API work to the initializer of the AppDelegate and this fixed the issue for us. So instead of calling AppAppearance.configure() after the app finished launching...we call it from AppDelegate.init and our Global Accent Color is now being honored.

Don't ask me why...I couldn't tell you.

I finally found a temporary workaround on this AppleDeveloperForum Thread

credit to: @chad_sykes for this answer

I found an alternate solution, which was to set the .accentColor on the main view in the WindowGroup and it gets used across the app.

@main
struct CurvApp: App {
    var body: some Scene {
        WindowGroup {
            myMainView
                .accentColor(CurvGlobalAppearance.curvAccentColor)
        }
    }
}
Related