Skip to content

Instantly share code, notes, and snippets.

@YannisDC
Created September 20, 2019 14:06
Show Gist options
  • Save YannisDC/9e9017c0b250e115ea7aa06313d71b62 to your computer and use it in GitHub Desktop.
Save YannisDC/9e9017c0b250e115ea7aa06313d71b62 to your computer and use it in GitHub Desktop.
Simple Apple Card Combined Radial Gradient Demo
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