A Popup PickerView or DatePickerView
pod 'AYPopupPickerView'
github "Aiur3908/AYPopupPickerView"
File -> Swift Packages -> Add Package Dependency
https://github.com/Aiur3908/AYPopupPickerView
Drag and drop source folder to your project.
let itemsTitle = ["Apple", "Avocado", "Banana", "Cherry", "Coconut", "Grape"]
let popupPickerView = AYPopupPickerView()
popupPickerView.display(itemTitles: itemsTitle, doneHandler: {
let selectedIndex = popupPickerView.pickerView.selectedRow(inComponent: 0)
print(itemsTitle[selectedIndex])
})
let popupDatePickerView = AYPopupDatePickerView()
popupDatePickerView.display(defaultDate: Date(), doneHandler: { date in
print(date)
})
public var pickerView: UIPickerView!
public var doneButton: UIButton!
public var cancelButton: UIButton!
public var headerView: UIView!
public var datePickerView: UIDatePicker!
public var doneButton: UIButton!
public var cancelButton: UIButton!
public var headerView: UIView!
let customPopupPickerView = AYPopupPickerView()
customPopupPickerView.headerView.backgroundColor = UIColor.green
customPopupPickerView.doneButton.setTitle("OK", for: .normal)
customPopupPickerView.doneButton.setTitleColor(.red, for: .normal)
customPopupPickerView.cancelButton.setTitleColor(.blue, for: .normal)
let customPopupDatePickerView = AYPopupDatePickerView()
customPopupDatePickerView.datePickerView.datePickerMode = .date
You can implementation UIPickerViewDataSource & UIPickerViewDelegate in your ViewController
class ViewController: UIViewController {
let popupPickerView = AYPopupPickerView()
override func viewDidLoad() {
super.viewDidLoad()
popupPickerView.pickerView.dataSource = self
popupPickerView.pickerView.delegate = self
}
@IBAction func display(_ sender: Any) {
popupPickerView.display(doneHandler: {
})
}
}
extension ViewController: UIPickerViewDataSource & UIPickerViewDelegate {
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 2
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return 5
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return "\(row)"
}
}
popupPickerView.display(itemTitles: itemsTitle, defaultIndex: 1, doneHandler: {
})
//defaultSelects: [(row: Int, component: Int)]
popupPickerView.display(with: [(2,0), (1,1)], doneHandler: {
})
Jerry You Email: Aiur3908@gmail.com
Pull requests, feature requests and bug reports are welcome 🚀
AYPopupPickerView is released under the MIT license. See LICENSE for details.