Skip to content

Commit 4190f6c

Browse files
authored
Add FlowerView example (#786)
1 parent 6989e7b commit 4190f6c

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

Example/SharedExample/ContentView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import OpenSwiftUI
1010
#else
1111
import SwiftUI
1212
#endif
13-
import Foundation
1413

1514
struct ContentView: View {
1615
var body: some View {
17-
InsetViewModifierExample()
16+
FlowerView()
1817
}
1918
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// FlowerView.swift
3+
// SharedExample
4+
5+
#if OPENSWIFTUI
6+
import OpenSwiftUI
7+
#else
8+
import SwiftUI
9+
#endif
10+
import Foundation
11+
12+
struct FlowerView: View {
13+
var body: some View {
14+
ZStack {
15+
ForEach(0..<6) { i in
16+
Capsule()
17+
.fill(i.isMultiple(of: 2) ? .primary : .secondary)
18+
.frame(width: 120, height: 40)
19+
.rotationEffect(.degrees(Double(i) * 30))
20+
.shadow(color: .purple, radius: 8, x: 4, y: 4)
21+
}
22+
}
23+
.foregroundStyle(.cyan, .orange)
24+
}
25+
}
26+
27+
struct FlowerViewAnimation: View {
28+
@State private var animate = false
29+
30+
var body: some View {
31+
ZStack {
32+
ForEach(0..<6) { i in
33+
Capsule()
34+
.fill(i.isMultiple(of: 2) ? .primary : .secondary)
35+
.frame(width: 120, height: 40)
36+
.rotationEffect(.degrees(Double(i) * 30))
37+
.shadow(color: .purple, radius: 8, x: 4, y: 4)
38+
}
39+
}
40+
.foregroundStyle(.cyan, .orange)
41+
.scaleEffect(animate ? 1.2 : 0.8)
42+
.rotationEffect(.degrees(animate ? 360 : 0))
43+
.animation(.easeInOut(duration: 2).repeatForever(autoreverses: true), value: animate)
44+
.task { animate = true }
45+
}
46+
}

0 commit comments

Comments
 (0)