我有以下锁屏小部件代码。我看到小部件的左侧和右侧有一个间隙,因此我的内容不太适合。我该如何修改它以确保矩形小部件的整个空间在任何 iPhone 上都被使用?
结构 RectangleWidgetView: 视图 { var 条目:WorldClockProvider.Entry
var body: some View {
VStack(alignment: .leading) {
ForEach(entry.cities.prefix(3), id: \.name) { city in
HStack {
Text(getCityAbbreviation(for: city.name))
.font(.system(size:11))
.fontWeight(.bold)
Spacer()
Text(getTime(for: city.timeZone, date: entry.date))
.font(.system(size: 09))
.fontWeight(.bold)
.frame(maxWidth: .infinity, alignment: .trailing) // Set fixed width and right-align the text
}
}
Spacer()
}
.padding()
.widgetAccentable()
}
尝试更换垫片但不起作用
删除 .padding() 修饰符或设置填充参数。 请参阅:Apple 开发人员填充文档