Skip to content

Instantly share code, notes, and snippets.

@haneenmahd
Created June 3, 2022 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haneenmahd/733f145b71f4053809553e20c4a96d04 to your computer and use it in GitHub Desktop.
Save haneenmahd/733f145b71f4053809553e20c4a96d04 to your computer and use it in GitHub Desktop.
Ripple Effect in SwiftUI
import SwiftUI
struct ContentView: View {
@State private var firstCircle = 1.0
@State private var secondCircle = 1.0
var body: some View {
ZStack {
Circle()
.stroke(.blue)
.scaleEffect(firstCircle)
.opacity(2 - firstCircle)
.onAppear {
withAnimation(.easeInOut(duration: 3).repeatForever(autoreverses: false)) {
firstCircle = 3
}
}
Circle()
.stroke(.blue)
.scaleEffect(secondCircle)
.opacity(2 - secondCircle)
.onAppear {
withAnimation(.easeInOut(duration: 3).repeatForever(autoreverses: false)) {
secondCircle = 2
}
}
}
.padding(50)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment