Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save andresr-dev/5353433445cb8abc0ea6a0b5fe40b571 to your computer and use it in GitHub Desktop.

Select an option

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.
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