I created a TextView without any color modifiers. It turns out as light gray in both Light Mode and Dark Mode. However, it's too light and nearly invisible in Dark Mode.
Based on my research, iOS will dynamically change the color appropriately as long as I use a system color. I found those here:
https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/#system-colors
But, when I use the foregroundColor modifier, it doesn't change the text color, regardless if the phone is in Light or Dark Mode. And I've tried setting the modifier directly on the TextField and on the encompassing HStack to no avail. When modifying the HStack, though, it properly modifies the Image. I've tried a couple different grays and a purple.
I'm not sure if I'm doing something wrong, don't understand TextView or have found a bug. Here's my code snippet:
struct UsernameTextField: View {
@Binding var username: String
var body: some View {
HStack {
Image(systemName: "person")
TextField("Username", text: $username)
.autocapitalization(.none)
.disableAutocorrection(true)
.foregroundColor(Color(.systemPurple))
}
.foregroundColor(Color(.systemPurple))
.padding(.all, 20)
.cornerRadius(8)
.background(Color.white)
}
}
I'm using Xcode 12 Beta 3 and building for iOS 14.
Same behavior in Preview, Simulator and via TestFlight.