我创建列表并在其中添加 VStack 并在 VStack 中添加了一些视图。当我运行该项目时,我观察到 List 的滚动超出了安全区域。仅供参考,如果我删除 Frame 属性仍然是相同的结果。模拟器gif
struct ContentView : View {
var body: some View {
List(0..<5) { item in
HStack(alignment: VerticalAlignment.top, spacing: 5) {
Image(systemName: "photo")
VStack(alignment: HorizontalAlignment.leading, spacing: 10) {
Text("USA")
.font(.headline)
Text("This is an extremely long string that will never fit even the widest of Phones Excerpt From: Paul Hudson. “SwiftUI by Example”. Apple Books. ")
.lineLimit(nil)
.font(.subheadline)
}
}
}
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.background(Color.red)
.onAppear() {
print("on …Run Code Online (Sandbox Code Playgroud)