Created
September 20, 2019 14:06
-
-
Save YannisDC/9e9017c0b250e115ea7aa06313d71b62 to your computer and use it in GitHub Desktop.
Simple Apple Card Combined Radial Gradient Demo
This file contains 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 ContentView: View { | |
@State var show = false | |
var body: some View { | |
VStack{ | |
ZStack{ | |
Rectangle() | |
.fill(Color.white) | |
.frame(width: 300, height: 200) | |
Rectangle() | |
.fill(RadialGradient(gradient: Gradient(colors: [.orange, .white]), center: show ? UnitPoint(x: 0.3, y: 0.3) : UnitPoint(x: -0.3, y: -1.0), startRadius: 5, endRadius: 100)) | |
.animation(.easeInOut(duration: 0.5)) | |
.frame(width: 300, height: 200) | |
Rectangle() | |
.fill(RadialGradient(gradient: Gradient(colors: [.yellow, .white]), center: show ? UnitPoint(x: 0.75, y: 0.75) : UnitPoint(x: 2.0, y: 2.0), startRadius: 5, endRadius: 150)) | |
.animation(.easeInOut(duration: 0.5)) | |
.frame(width: 300, height: 200) | |
Rectangle() | |
.fill(RadialGradient(gradient: Gradient(colors: [.purple, .white]), center: show ? UnitPoint(x: 0.0, y: 0.75) : UnitPoint(x: 0.0, y: 2.0), startRadius: 5, endRadius: 100)) | |
.animation(.easeInOut(duration: 0.5)) | |
.frame(width: 300, height: 200) | |
Rectangle() | |
.fill(RadialGradient(gradient: Gradient(colors: [.green, .white]), center: show ? UnitPoint(x: 0.75, y: 0.0) : UnitPoint(x: 1.0, y: -2.0), startRadius: 5, endRadius: 50)) | |
.animation(.easeInOut(duration: 0.5)) | |
.frame(width: 300, height: 200) | |
} | |
.blur(radius: 20) | |
.blendMode(.multiply) | |
.clipped() | |
.cornerRadius(10) | |
.shadow(color: Color.gray.opacity(0.5), radius: 5, y: 2) | |
Toggle(isOn: $show) { | |
Text("text") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment