-
-
Save sturdysturge/ca0cf209ea47dbf6290ecfbe3ba83d31 to your computer and use it in GitHub Desktop.
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 | |
| extension BlendMode: Identifiable, CaseIterable { | |
| public var id: Self { self } | |
| public static var allCases: [BlendMode] { | |
| [.color, .colorBurn, .colorDodge, | |
| .darken, .destinationOut, .destinationOver, | |
| .difference, .exclusion, .hardLight, | |
| .hue, .lighten, .luminosity, | |
| .multiply, .normal, .overlay, | |
| .plusDarker, .plusLighter, .saturation, | |
| .screen, .softLight, .sourceAtop] | |
| } | |
| } | |
| struct ContentView: View { | |
| @State var blendMode = BlendMode.color | |
| var body: some View { | |
| List { | |
| Section("Blend Mode") { | |
| Picker("", selection: $blendMode) { | |
| ForEach(BlendMode.allCases) { mode in | |
| Text(String(describing: mode)) | |
| } | |
| } | |
| } | |
| Section("Demo") { | |
| ZStack { | |
| Text("View One") | |
| .padding() | |
| .background(Color.green) | |
| .foregroundColor(.white) | |
| .blendMode(blendMode) | |
| Text("View Two") | |
| .offset(x: 15, y: 15) | |
| .padding() | |
| .background(Color.blue) | |
| .foregroundColor(.white) | |
| .blendMode(blendMode) | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment