File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed
SharedExample/Animation/Animation Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,6 @@ class ViewController: NSViewController {
6666
6767struct ContentView : View {
6868 var body : some View {
69- ToggleExample ( )
69+ RepeatAnimationExample ( )
7070 }
7171}
Original file line number Diff line number Diff line change 1+ //
2+ // RepeatAnimationExample.swift
3+ // SharedExample
4+
5+ #if OPENSWIFTUI
6+ import OpenSwiftUI
7+ #else
8+ import SwiftUI
9+ #endif
10+
11+ struct RepeatAnimationExample : View {
12+ @State private var smaller = false
13+
14+ var body : some View {
15+ VStack {
16+ HStack {
17+ Color . red
18+ . frame ( width: smaller ? 50 : 100 , height: smaller ? 50 : 100 )
19+ . animation (
20+ . linear( duration: 1 ) . repeatCount ( 2 , autoreverses: false ) ,
21+ value: smaller,
22+ )
23+ Color . green
24+ . frame ( width: smaller ? 50 : 100 , height: smaller ? 50 : 100 )
25+ . animation (
26+ . linear( duration: 1 ) . repeatCount ( 2 , autoreverses: true ) ,
27+ value: smaller,
28+ )
29+ }
30+ HStack {
31+ Color . red
32+ . frame ( width: smaller ? 50 : 100 , height: smaller ? 50 : 100 )
33+ . animation (
34+ . linear( duration: 1 ) . repeatForever ( autoreverses: false ) ,
35+ value: smaller,
36+ )
37+ Color . green
38+ . frame ( width: smaller ? 50 : 100 , height: smaller ? 50 : 100 )
39+ . animation (
40+ . linear( duration: 1 ) . repeatForever ( autoreverses: true ) ,
41+ value: smaller,
42+ )
43+ }
44+ }
45+ . onAppear {
46+ smaller. toggle ( )
47+ }
48+ }
49+ }
You can’t perform that action at this time.
0 commit comments