-
-
Save chriseidhof/68b2cf3a993f6f5771c821db38d3c79e to your computer and use it in GitHub Desktop.
This file contains 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
import SwiftUI | |
extension View { | |
func debugLog(_ name: String) -> some View { | |
MyLayout(name: name) { self } | |
} | |
} | |
struct MyLayout: Layout { | |
var name: String | |
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { | |
assert(subviews.count == 1) | |
let result = subviews[0].sizeThatFits(proposal) | |
print(name, proposal, result) | |
return result | |
} | |
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) { | |
subviews[0].place(at: bounds.origin, proposal: proposal) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment