I think there are two confounding issues here. The first is that the default accentColor is not intended to be used as a background color, and its high contrast versions reduce rather than increase contrast with .primary color text (in both light and dark themes).
NavigationSplitView & Passwords are both using the default accentColor while Contacts and Messages are both probably using a custom color as a background, which have high contrast versions that are intended to be used as a background for .primary color text.
The other issue is much more difficult to work around, which is that certain views aren't actually using the high contrast version of the color, but are further amplifying these colors programmatically, even if you do specify a high contrast color. I think this is based on whether they are contained inside other UIKit-based views, but I am very not sure.
import SwiftUI
@main
struct HighContrastBlueDemoApp: App {
var body: some Scene {
WindowGroup { ContentView() }
}
}
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Color.accentColor
.overlay {
Text("Color.accentColor — NOT in NavigationStack")
.foregroundStyle(.white)
}
NavigationStack {
Color.accentColor
.overlay {
Text("Color.accentColor — inside NavigationStack")
.foregroundStyle(.white)
}
.toolbar(.hidden, for: .navigationBar)
}
}
.ignoresSafeArea()
}
}
#Preview { ContentView() }
This means that even if I specify a high contrast color in an asset file, I can't use it consistently. I assume everyone is working around this with hardcoded sRBG values, or just letting their app get ugly in Increased Contrast mode, but I haven't gotten there yet.
Please let me know if I've done something inane.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: