Created
January 23, 2022 11:10
-
-
Save SarahAlsharif/d2fe0c3f08c5f736c8ead8122bc6d561 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
| struct AnimatedCircle: View { | |
| @State var val = 0.0 | |
| @State var scale = 0.2 | |
| var body: some View { | |
| ZStack { | |
| Circle() | |
| .stroke(.black.opacity(0.07),lineWidth: 23) | |
| .frame(width: 220, height: 220) | |
| Circle() | |
| .trim(from: 0, to: val) | |
| .stroke(style: StrokeStyle(lineWidth: 20, lineCap: .round, lineJoin: .miter, miterLimit: 10)) | |
| .foregroundColor(.mint.opacity(0.7)) | |
| .frame(width: 220, height: 220) | |
| .onAppear { | |
| withAnimation (.spring(dampingFraction: 0.4)) { | |
| val = 0.65 | |
| } | |
| withAnimation (.spring(dampingFraction: 0.48)){ | |
| scale = 1.0 | |
| } | |
| } | |
| .modifier(AnimationModifier(positionOffset: 0)) | |
| HStack { | |
| Text("65") | |
| .font(.system(size: 85)) | |
| .bold() | |
| Text("%") | |
| .font(.system(size: 45)) | |
| .bold() | |
| }.offset(x: 10) | |
| .scaleEffect(scale) | |
| .modifier(AnimationModifier(positionOffset: 0)) | |
| .foregroundColor(.black.opacity(0.7)) | |
| } | |
| .frame(height: 400) | |
| .background(.mint.opacity(0.5)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment