Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to change the calendar type of UIDatePicker #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/DatePickerDialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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))
Expand All @@ -46,6 +48,7 @@ open class DatePickerDialog: UIView {
self.font = font
self.showCancelButton = showCancelButton
self.locale = locale
self.calendar = calendar
setupView()
}

Expand Down Expand Up @@ -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() }
Expand Down