-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimations.swift
37 lines (31 loc) · 948 Bytes
/
Animations.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import SwiftUI
struct Animations: View {
@State var isAnimated: Bool = false
var body: some View {
VStack {
Button("Animate") {
isAnimated.toggle()
}
Spacer()
RoundedRectangle(cornerRadius: isAnimated ? 50 : 25)
.fill(isAnimated ? .green : .red)
.frame(
width: isAnimated ? 100 : 300,
height: isAnimated ? 100 : 300
)
.rotationEffect(.degrees(isAnimated ? 360 : 0))
.offset(y: isAnimated ? 300 : 0)
.animation(
Animation
.default
// .repeatCount(5, autoreverses: false)
.repeatForever(),
value: isAnimated
)
Spacer()
}
}
}
#Preview {
Animations()
}