Created
April 26, 2022 17:33
-
-
Save andresr-dev/5353433445cb8abc0ea6a0b5fe40b571 to your computer and use it in GitHub Desktop.
This is an example of how you can support differentiation without color in your applications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct DifferentiateWithoutColorExample: View { | |
| @Environment(\.accessibilityDifferentiateWithoutColor) var differentiateWithoutColor | |
| var body: some View { | |
| HStack { | |
| if differentiateWithoutColor { | |
| Image(systemName: "checkmark.circle") | |
| } | |
| Text("Success") | |
| } | |
| .padding() | |
| .background(differentiateWithoutColor ? .black : .green) | |
| .foregroundColor(.white) | |
| .clipShape(Capsule()) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment