gpt4 book ai didi

swift - 如何在 SwiftUI 中扩大列表范围?

转载 作者:行者123 更新时间:2023-11-30 10:28:22 24 4
gpt4 key购买 nike

我现在正在学习 SwiftUI,并且正在编写教程。

但在 SwiftUI List 中,名称部分如图所示被剪切。你有修改器吗?

struct ContentView: View {
var body: some View {
List(modelData) {
Device in HStack {
Image(systemName: Device.image)
.frame(width: 50, height: 10, alignment: .leading)
Text("\(Device.name)")
.frame(width: 50, height: 10, alignment: .leading)
.scaledToFit()
VStack {
Text("\(Device.price)")
}
}
.font(.title)
}
}

}

enter image description here

最佳答案

而不是像你那样限制

    Text("\(Device.name)")
.frame(width: 50, height: 10, alignment: .leading)
.scaledToFit()

仅使用

    Text("\(Device.name)")

它会自动调整大小以适合

关于swift - 如何在 SwiftUI 中扩大列表范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59676183/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com