From 2fef61ef07bb2779de68db6825abb7a24fffc872 Mon Sep 17 00:00:00 2001 From: Hossain Alhaidari Date: Mon, 8 Oct 2018 12:28:29 +0330 Subject: [PATCH] Added the ability to change the calendar type of UIDatePicker --- Sources/DatePickerDialog.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/DatePickerDialog.swift b/Sources/DatePickerDialog.swift index 880479d..621e567 100644 --- a/Sources/DatePickerDialog.swift +++ b/Sources/DatePickerDialog.swift @@ -28,6 +28,7 @@ open class DatePickerDialog: UIView { private var callback: DatePickerCallback? var showCancelButton: Bool = false var locale: Locale? + var calendar: Calendar? private var textColor: UIColor! private var buttonColor: UIColor! @@ -38,6 +39,7 @@ open class DatePickerDialog: UIView { buttonColor: UIColor = UIColor.blue, font: UIFont = .boldSystemFont(ofSize: 15), locale: Locale? = nil, + calendar: Calendar? = nil, showCancelButton: Bool = true) { let size = UIScreen.main.bounds.size super.init(frame: CGRect(x: 0, y: 0, width: size.width, height: size.height)) @@ -46,6 +48,7 @@ open class DatePickerDialog: UIView { self.font = font self.showCancelButton = showCancelButton self.locale = locale + self.calendar = calendar setupView() } @@ -103,6 +106,9 @@ open class DatePickerDialog: UIView { if let locale = self.locale { self.datePicker.locale = locale } + if let calendar = self.calendar { + self.datePicker.calendar = calendar + } /* Add dialog to main window */ guard let appDelegate = UIApplication.shared.delegate else { fatalError() } guard let window = appDelegate.window else { fatalError() }