如何更改日期选择器(SwiftUI)中日期的字体大小

时间:2020-06-03 01:51:00

标签: swiftui

如何使用SwiftUI在DatePicker中缩小日期的字体?

struct TestView: View {
    @State private var eventDate = Date()

    var body: some View {
        ZStack {
            Color(.purple).edgesIgnoringSafeArea(.all)
            VStack {
                Section {
                    DatePicker("Event Date", selection: $eventDate, in: ...Date())
                    .labelsHidden()
                }
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您可以应用var body: some View { ZStack { Color(.purple).edgesIgnoringSafeArea(.all) VStack { Section { DatePicker("Event Date", selection: $eventDate, in: ...Date()) .labelsHidden() .transformEffect(.init(scaleX: 0.7, y: 0.7)) } } } }

{{1}}