CS0521
CS0521

Reputation: 182

How can I change font size of the dates within the datepicker (SwiftUI)

How can I make the font of the dates smaller in the DatePicker using SwiftUI?

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()
                }
            }
        }
    }
}

Upvotes: 8

Views: 4013

Answers (1)

paulRick
paulRick

Reputation: 604

You can apply a .transformEffect(.init(scaleX: 0.7, y: 0.7)):

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))
            }
        }
    }
}

Upvotes: 8

Related Questions