Created
January 22, 2024 02:46
-
-
Save heestand-xyz/a86b633e79227f958544057bccf9ef58 to your computer and use it in GitHub Desktop.
Frame Layout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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