Created
June 3, 2022 15:13
-
-
Save haneenmahd/733f145b71f4053809553e20c4a96d04 to your computer and use it in GitHub Desktop.
Ripple Effect in SwiftUI
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 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