File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Sources/SwiftCrossUI/Views Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
1
public struct ZStack < Content: View > : View {
2
+ public var alignment : Alignment
2
3
public var body : Content
3
4
4
- public init ( @ViewBuilder content: ( ) -> Content ) {
5
- self . init ( content: content ( ) )
5
+ public init (
6
+ alignment: Alignment = . center,
7
+ @ViewBuilder content: ( ) -> Content
8
+ ) {
9
+ self . init (
10
+ alignment: alignment,
11
+ content: content ( )
12
+ )
6
13
}
7
14
8
- init ( content: Content ) {
15
+ init ( alignment: Alignment , content: Content ) {
16
+ self . alignment = alignment
9
17
body = content
10
18
}
11
19
@@ -56,7 +64,10 @@ public struct ZStack<Content: View>: View {
56
64
57
65
if !dryRun {
58
66
for (i, childSize) in childSizes. enumerated ( ) {
59
- let position = ( size. size &- childSize. size) / 2
67
+ let position = alignment. position (
68
+ ofChild: childSize. size,
69
+ in: size. size
70
+ )
60
71
backend. setPosition ( ofChildAt: i, in: widget, to: position)
61
72
}
62
73
backend. setSize ( of: widget, to: size. size)
You can’t perform that action at this time.
0 commit comments