Skip to content

Instantly share code, notes, and snippets.

@heestand-xyz
Created January 22, 2024 02:46
Show Gist options
  • Save heestand-xyz/a86b633e79227f958544057bccf9ef58 to your computer and use it in GitHub Desktop.
Save heestand-xyz/a86b633e79227f958544057bccf9ef58 to your computer and use it in GitHub Desktop.
Frame Layout
struct FrameLayout: Layout {
let frame: CGRect
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
CGSize(
width: proposal.width ?? 0.0,
height: proposal.height ?? 0.0
)
}
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
for subview in subviews {
subview.place(
at: bounds.origin + frame.origin,
anchor: .topLeading,
proposal: ProposedViewSize(
width: frame.width,
height: frame.height
)
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment