File tree 3 files changed +45
-0
lines changed
Samples/LayoutAdjustments
SwiftUIPlayground.xcodeproj/project.xcworkspace/xcuserdata/tahatesser.xcuserdatad
3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ public let samples: [String: AnyView] = [
43
43
" Container Relative Frame " : AnyView ( ContainerRelativeFrameSample ( ) ) ,
44
44
// https://developer.apple.com/documentation/swiftui/view/safeareainset(edge:alignment:spacing:content:)-6gwby
45
45
" safeAreaInset " : AnyView ( SafeAreaInsetSample ( ) ) ,
46
+ // https://developer.apple.com/documentation/swiftui/view/alignmentguide(_:computevalue:)-6y3u2
47
+ " alignmentGuide " : AnyView ( AlignmentGuideSample ( ) ) ,
46
48
]
47
49
) ) ,
48
50
" Drawing and Graphics " : AnyView ( SamplesList (
Original file line number Diff line number Diff line change
1
+ //
2
+ // AlignmentGuideSample.swift
3
+ // SwiftUIPlayground
4
+ //
5
+ // Created by Taha Tesser on 10/14/24.
6
+ //
7
+
8
+ import SwiftUI
9
+
10
+ struct AlignmentGuideSample : View {
11
+
12
+ var body : some View {
13
+ VStack ( alignment: . leading) {
14
+ RoundedRectangle ( cornerRadius: 20 )
15
+ . fill ( Color . red)
16
+ . frame ( width: 50 , height: 200 )
17
+ // .alignmentGuide(.leading, computeValue: { dimension in
18
+ // -100
19
+ // })
20
+ . alignmentGuide ( . leading, computeValue: { dimension in
21
+ dimension [ . trailing]
22
+ } )
23
+ Text ( " Testing the alignment " )
24
+ . border ( . orange)
25
+ . frame ( width: 250 , height: 50 )
26
+ // .alignmentGuide(.leading, computeValue: { dimension in
27
+ // dimension[.trailing]
28
+ // })
29
+ RoundedRectangle ( cornerRadius: 20 )
30
+ . fill ( Color . blue)
31
+ . frame ( width: 100 , height: 100 )
32
+ RoundedRectangle ( cornerRadius: 20 )
33
+ . fill ( Color . green)
34
+ . frame ( width: 50 , height: 50 )
35
+ }
36
+
37
+ }
38
+
39
+ }
40
+
41
+ #Preview {
42
+ AlignmentGuideSample ( )
43
+ }
You can’t perform that action at this time.
0 commit comments