Writen in Swift 4.2 - XCode 11.3
iOS 11.+
This is a repository of my custom PickerView! This plugin is simple and ready to go!
- Custom DatePicker View
- Can change color of almost everything
- Animation Bottom to Top only :(
- Create a XCode Proj example
You can use CocoaPods to install LCEssentials
by adding it to your Podfile
:
platform :ios, '10.0'
use_frameworks!
pod 'LCEssentials/PickerViews'
Import LCEssentials
wherever you import UIKit.
To get the full benefits of LCEssentials
see the README
import LCEssentials
- DatePickerViewController
class MyCustomViewController: UIViewController, DatePickerViewControllerDelegate {
//Use this custom instantiate
let datePickerController: DatePickerViewController = DatePickerViewController.instantiate()
override func viewDidLoad(){
super.viewDidLoad()
datePickerController.delegate = self
//For hour
datePickerController.setDatePickerMode = .time
datePickerController.setFormat = "HH:mm"
//If you whant a date format, you can pre-select a date
//datePickerController.setSelectedDate = "30/06/2020"
}
func showPicker(){
if datePickerController.isHidden {
datePickerController.show()
}
}
// You can use multiple instance of it!
// So, on delegate methods, check the instance
// and work with it
//MARK: - DatePickerController Delegate
func datePickerViewController(didConfirm picker: DatePickerViewController, withValue: String) {
if picker == self.datePickerController {
//Do something with the date value in String or
//grab picker.date for Date object
}
}
func datePickerViewController(didCancel picker: DatePickerViewController) {
//Do something when canceled
}
func datePickerViewController(didEndScrollPicker picker: DatePickerViewController, withValue: String) {
//Grab date value in String or picker.date Date object on every scroll ended
}
}
Any question or doubts, please send thru email
Daniel Arantes Loverde - daniel@loverde.com.br