【发布时间】:2021-08-30 09:43:55
【问题描述】:
我的代码如下:
struct DotView: View {
var body: some View {
GeometryReader { geo in
let width = geo.size.width
HStack() {
VStack() {
Circle()
.frame(width: width, height: width)
Spacer()
Circle()
.frame(width: width, height: width)
}
}
}
}
}
struct TestView: View {
var body: some View {
HStack() {
Text("09")
DotView()
.frame(width: 7, height: 30, alignment: .center)
Text("22")
Text("PM")
.font(.system(size: 20))
}
.font(.system(size: 66, weight: .medium))
}
}
struct TestView_Previews: PreviewProvider {
static var previews: some View {
TestView()
}
}
结果如下图,所有视图都居中对齐。
如何使“pm”在底部对齐“09”和“22”,如下图?
【问题讨论】: