从屏幕快照中可以看到,Text
中的两个VStack
保持与文本视图的左边缘对齐,但未对齐实际内容。如何在视图而不是视图中对齐文本内容?
struct Content: View {
var body: some View {
return VStack(alignment: .leading) {
Text("LARGE")
.lineLimit(1)
.font(
.system(size: 120.0,
weight: .medium, design: .monospaced))
Text("SMALL")
.lineLimit(1)
.font(.system(size: 50.0,
weight: .medium, design: .monospaced))
}
}
}
PlaygroundPage.current.setLiveView(Content())