swift - 如何在 SwiftUI 中使列表更宽?
问题描述
我现在正在学习 SwiftUI,并且正在编写教程。
但是在 SwiftUI List 中,name 的部分被剪掉了。你有修饰符吗?
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)
}
}
}
解决方案
而不是像你一样限制
Text("\(Device.name)")
.frame(width: 50, height: 10, alignment: .leading)
.scaledToFit()
只用
Text("\(Device.name)")
它将自动调整大小以适合
推荐阅读
- c++ - 如何从输入字符串制作二维向量?
- python - 如何使用 sqlalchemy 避免全局变量
- graphql - 无法读取未定义的属性“授权”
- javascript - 具有 Google Apps 脚本值的服务器端和客户端通信函数
- reactjs - Razorpay 说尝试创建实例时没有传递密钥
- three.js - 在 Three.js 中连接两个组件
- python - 如何调用名称仅在python中的变量中知道的函数?
- assembly - 程序集:错误 [66]:段太长(最大值为 ffff)
- python - Python 将列表中的每个数字视为一个单独的数字
- javascript - 每次循环打印一个数字