我有一个 GraphicalDatePickerStyle 的 DatePicker,我想将它放在矩形的中心。我的代码:
HStack {
Spacer()
DatePicker("", selection: $notificationTimeOnPicker, displayedComponents: .hourAndMinute).foregroundColor(Color("ChartColor")).labelsHidden()
.datePickerStyle(GraphicalDatePickerStyle())
Spacer()
}
Run Code Online (Sandbox Code Playgroud)
这就是我得到和想要的:
如何将 DatePicker 居中?看起来它的框架由于某种未知的原因而很宽。我尝试将其框架大小更改为宽度:95 或更小以将其居中,但之后在某些设备上打字时我得到...而不是数字。
它似乎只适用于 CompactDatePickerStyle
DatePicker("", selection: $notificationTimeOnPicker, displayedComponents: .hourAndMinute)
.foregroundColor(Color("ChartColor"))
.datePickerStyle(CompactDatePickerStyle())
.clipped()
.labelsHidden()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4020 次 |
最近记录: |