Mercurial > public > geoquiz
comparison GeoQuiz/Tests/Animation.swift @ 3:4dbe0cd9dadc
first game prototype
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 22 Sep 2022 10:42:39 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:5b7c89bd45c3 | 3:4dbe0cd9dadc |
---|---|
1 // | |
2 // Animation.swift | |
3 // GeoQuiz | |
4 // | |
5 // Created by Dennis Concepción Martín on 21/9/22. | |
6 // | |
7 | |
8 import SwiftUI | |
9 | |
10 struct Animation: View { | |
11 @State private var amount = 1.0 | |
12 | |
13 var body: some View { | |
14 Button { | |
15 withAnimation(.easeIn(duration: 0.5)) { | |
16 amount += 1 | |
17 } | |
18 | |
19 DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { | |
20 withAnimation(.easeIn(duration: 0.5)) { | |
21 amount = 1 | |
22 } | |
23 } | |
24 } label: { | |
25 Circle() | |
26 .overlay( | |
27 Text("Button") | |
28 .foregroundColor(.white) | |
29 ) | |
30 } | |
31 .frame(height: 100) | |
32 .scaleEffect(amount) | |
33 } | |
34 } | |
35 | |
36 struct Animation_Previews: PreviewProvider { | |
37 static var previews: some View { | |
38 Animation() | |
39 } | |
40 } |