[英]SwiftUI/Widget - Why the `Text` for `Date` takes so much space in HStack
Why the Text
for Date
takes so much space.为什么
Date
的Text
占用这么多空间。
var body: some View {
VStack{
HStack(alignment: .top, spacing: 0) {
VStack{
Text(entry.date, style:.relative)
}
.background(Color.yellow)
Text("ago")
}
.font(.system(size: 12))
.foregroundColor(.gray)
}.padding()
}
I would like to display the ago
static text right after the dynamic date Text
element in HStack我想在 HStack 中的动态日期
Text
元素之后显示ago
的 static 文本
I can simply do this:我可以简单地这样做:
Text("\(entry.date, style: .relative) ago")
and there is no need for a HStack
Text("\(entry.date, style: .relative) ago")
并且不需要HStack
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.