在 SwiftUI 运行其视图渲染阶段后,有没有办法测量视图的计算大小?例如,给定以下视图:
struct Foo : View {
var body: some View {
Text("Hello World!")
.font(.title)
.foregroundColor(.white)
.padding()
.background(Color.red)
}
}
Run Code Online (Sandbox Code Playgroud)
选择视图后,计算出的大小显示在左下角的预览画布中。有谁知道在代码中访问该大小的方法?
swiftui ×1