Skip to content

aguilarpgc/PGCDatePickerController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PGCDatePickerController

Swift License Platform

Installation

Manual

Add PGCDatePickerController folder into your project.

Usage

You just need to call the PGCDatePickerController method, and it will return a PGCDatePickerController instance.

You can pass a Date instance to make the default date selected

In the completion you obtain the date selected by the user.

let dateController = PGCDatePickerController.with(currentDateSelected: self.defaultDate) { [weak self] (date) in
            
	guard let self = self else { return }
	// 
	// Use date selected in completion
	// self.defaultDate = date
	//
}

Then, you need to present the view controller.

self.present(dateController, animated: false, completion: nil) 

Custom

You can OPTIONALLY setup options for the DatePicker using these variables declared in DatePickerOptions:

  • minuteInterval
  • mode
  • minimumDate
  • maximumDate
var datePickerOptions = DatePickerOptions()

datePickerOptions.minimumDate    = Date()
datePickerOptions.mode           = .dateAndTime
datePickerOptions.minuteInterval = 5

And send it as a parameter in the view controller creation

let dateController = PGCDatePickerController.with(currentDateSelected: self.defaultDate, withOptions: datePickerOptions) { [weak self] (date) in
            
	guard let self = self else { return }
	// 
	// Use date selected in completion
	// self.defaultDate = date
	//
}
        
self.present(dateController, animated: false, completion: nil)

Example

Alt Text

License

This program is free software; you can redistribute it and/or modify it under the terms of the MIT License.

Releases

No releases published

Packages

No packages published

Languages