【发布时间】:2020-06-01 21:07:18
【问题描述】:
我有一个 swift 视图,它由一个带有矩形的 HStack 和一个内部文本的 Vstack 组成。我想让矩形的高度与 Vstack 的高度相同。我已经尝试在 StackOverflow 上查看许多其他问题,但没有找到答案。有人可以帮我做吗?
这是我的代码:
struct TodoView: View {
@State var todos = ["feed the dog", "take the dog out for a walk", "make coffee"]
@State var height: CGFloat = 45
var body: some View {
HStack{
RoundedRectangle(cornerRadius: 2)
.frame(width: 1)
.foregroundColor(Color("lightGray"))
.padding()
VStack{
Text("Todo")
.font(.title)
ForEach(todos, id: \.self){ todo in
Text(todo)
}
}
Spacer()
}
}
}
【问题讨论】: