Skip to content

Commit

Permalink
alignmentguide sample
Browse files Browse the repository at this point in the history
  • Loading branch information
TahaTesser committed Oct 14, 2024
1 parent 52dea7b commit 8950500
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Binary file not shown.
2 changes: 2 additions & 0 deletions SwiftUIPlayground/Samples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public let samples: [String: AnyView] = [
"Container Relative Frame": AnyView(ContainerRelativeFrameSample()),
// https://developer.apple.com/documentation/swiftui/view/safeareainset(edge:alignment:spacing:content:)-6gwby
"safeAreaInset": AnyView(SafeAreaInsetSample()),
// https://developer.apple.com/documentation/swiftui/view/alignmentguide(_:computevalue:)-6y3u2
"alignmentGuide": AnyView(AlignmentGuideSample()),
]
)),
"Drawing and Graphics": AnyView(SamplesList(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// AlignmentGuideSample.swift
// SwiftUIPlayground
//
// Created by Taha Tesser on 10/14/24.
//

import SwiftUI

struct AlignmentGuideSample: View {

var body: some View {
VStack(alignment: .leading) {
RoundedRectangle(cornerRadius: 20)
.fill(Color.red)
.frame(width: 50, height: 200)
// .alignmentGuide(.leading, computeValue: { dimension in
// -100
// })
.alignmentGuide(.leading, computeValue: { dimension in
dimension[.trailing]
})
Text("Testing the alignment")
.border(.orange)
.frame(width: 250, height: 50)
// .alignmentGuide(.leading, computeValue: { dimension in
// dimension[.trailing]
// })
RoundedRectangle(cornerRadius: 20)
.fill(Color.blue)
.frame(width: 100, height: 100)
RoundedRectangle(cornerRadius: 20)
.fill(Color.green)
.frame(width: 50, height: 50)
}

}

}

#Preview {
AlignmentGuideSample()
}

0 comments on commit 8950500

Please sign in to comment.