SwiftUI iPad、DatePickerのStyle検討

Example Code

import SwiftUI

struct ExportToPDFView: View {
    @State var selectingFrom: Date = Date()
    @State var selectingTo: Date = Date()

    var body: some View {
        VStack {
            Text("Select Day")
                    .font(.largeTitle)
            DatePicker("", selection: self.$selectingFrom, displayedComponents: [.date])
                .datePickerStyle(DefaultDatePickerStyle())
                .labelsHidden()
            HStack {
                Spacer()
                Button(action: {
                }, label: {
                    Text("Select")
                        .font(.largeTitle)
                })
                Spacer()
                Button(action: {
                }, label: {
                    Text("Cancel")
                        .font(.largeTitle)
                })
                Spacer()
            }
        }
    }
}

.datePickerStyle(DefaultDatePickerStyle())でStyleを適用する。
・CompactDatePickerStyle
・GraphicalDatePickerStyle
・WheelDatePickerStyle

FieldDatePickerStyleとStepperFieldDatePickerStyleはiPadで使用出来ない。

Swift

Posted by shi-n