aguilarpgc / PGCDatePickerController

UIViewController container for UIDatePicker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

UIViewController container for UIDatePicker

License:MIT License


Languages

Language:Swift 100.0%