Reputation: 984
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.
This is my project settings page where you can see that the accent color is correct.
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.
Upvotes: 6
Views: 3867
Reputation: 167
I was having similar issue with UIKit
. After setting AccentColor
in asset catalog everything worked accept some of the UI component like UIAlertController
option.
It worked after setting window tintColor in SceneDelegate
(or AppDelegate
).
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// ...
window?.windowScene = windowSence
// ...
}
Upvotes: 0
Reputation: 984
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)
}
}
}
Upvotes: 3
Reputation: 121
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.
Upvotes: 3