【发布时间】:2019-06-17 11:40:27
【问题描述】:
在你下面看到图像和我想拉伸到红色边框的黑色方块。
我已经尝试了以下
import SwiftUI
struct ContentView : View {
var body: some View {
HStack(spacing: 1) {
Rectangle().frame(width:20).foregroundColor(.red).frame(width:20)
ScrollView {
VStack {
ForEach(0..<5) { index in
Rectangle().frame(minWidth: 50, maxWidth: .infinity, minHeight: 50, maxHeight: 50)
}
}.relativeWidth(1)
}
Rectangle().foregroundColor(.red).frame(width:20)
}
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View { ContentView() }
}
#endif
但结果是这样的:
【问题讨论】:
-
它似乎是重复的......对不起。 (..但是这个问题的措辞要简单得多来证明这个问题?)
-
@Rivera 没有。我已经接受了在这里有效的答案。此外,关于您链接到的那个问题,该问题的答案是我的答案,链接到此处的答案。