Skip to content

Commit 7551525

Browse files
committed
Demonstrate ZStack alignment in the stacks gallery screen
1 parent eb91366 commit 7551525

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎Demo/App.swiftpm/Sources/StacksScreen.swift‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,30 @@ struct StacksScreen: View {
2626
Text("Lazy one")
2727
Text("Lazy two, longer")
2828
}
29+
Divider()
30+
ZStackSection(title: "ZStack .center", alignment: .center)
31+
ZStackSection(title: "ZStack .topLeading", alignment: .topLeading)
32+
ZStackSection(title: "ZStack .bottomTrailing", alignment: .bottomTrailing)
33+
}
34+
}
35+
}
36+
}
37+
38+
struct ZStackSection: View {
39+
40+
let title: String
41+
42+
let alignment: Alignment
43+
44+
var body: some View {
45+
VStack(spacing: 8) {
46+
Text(title)
47+
ZStack(alignment: alignment) {
48+
Color.blue
49+
.frame(width: 240, height: 120)
50+
Text("On top")
2951
}
52+
Divider()
3053
}
3154
}
3255
}

0 commit comments

Comments
 (0)