ios - 在 SwiftUI 中添加 Rectangle() 时单元格行自动调整大小损坏
问题描述
我无法Rectangle()
在水平堆栈中定位简单。如果我添加它,Text()
停止调整大小是这样的:
如果我删除Rectangle()
,炒锅罚款:
我尝试更改 frame、relativeSize、layoutPriority 等等,但没有任何效果。我认为这是一个错误,但对于任何类型的几何类型(如 Circle、RoundedRectangle 等)都失败了。另一方面,Image()
它工作正常。
有什么建议吗?
谢谢!
解决方案
只是从我的脑海中写出来,可能是错误的,但是尝试在 VStack 中添加矩形,这样它就不会将单元格包裹在它周围。
VStack {
Rectangle()
Spacer()
}
让我知道它是否有效。
编辑*
必须尝试一下,并找到一个“有点”的解决方案,它可能会引导您正确答案,您只需将矩形放置在右上角。将此作为您的 RowItem。
ZStack {
Rectangle()
.foregroundColor(Color.red)
.frame(width: 10, height: 10)
Text("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.")
.lineLimit(nil)
.layoutPriority(999)
.padding(.horizontal, 20)
}
推荐阅读
- docker - 如何从 Docker 打印(到打印机)
- sql - 如何在 SQL 中执行单元格引用之类的操作?
- javascript - 尝试在 CSS 中使用绝对位置时出现问题
- node.js - Node.js E00007 Authorize.net 错误 - 由于身份验证值无效,用户身份验证失败
- java - 页面必须填满整个 ViewPager2(使用 match_parent),而我将其设置为匹配父级
- pandas - Pandas 在某些列上合并;对于其他一些列,如果不是 NaN,请向左
- c++ - 为什么 msg.message 在我的程序中不等于 WM_QUIT
- python - 用于非图像矩阵的 Keras CNN
- javascript - Node.js - 获取 routes.js 的目录
- python - 给定字典和列表的频率计数