【发布时间】:2020-03-26 21:02:55
【问题描述】:
如果容器 (VStack) 与底部黑色视图不冲突,如何设置 rgb 视图 (100pt) 之间的默认间距。(如 iPhone 11 Pro Max)。 BUT 如果没有 100p 高度的空间,则会缩小。(如屏幕截图上的 iPhone SE)
我的代码:
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
VStack(spacing: 0) {
Rectangle()
.foregroundColor(.red)
.frame(height: 100)
Spacer()
.frame(minHeight: 10, maxHeight: 100)
Rectangle()
.foregroundColor(.green)
.frame(height: 100)
Spacer()
.frame(minHeight: 10, maxHeight: 100)
Rectangle()
.foregroundColor(.blue)
.frame(height: 100)
}
Spacer()
.frame(minHeight: 10, maxHeight: 600)
Rectangle() // keyboard
.frame(height: 200)
}
}
}
所以问题是: maxHeight: 100 的垫片在 iPhone 11 Pro Max 上的高度 = 10(不是 100)。 (但是黑色视图和 VStack 之间的空间允许它)
如何做出我解释的行为?
【问题讨论】:
标签: ios swift layout constraints swiftui