D2PDatePicker
Elegant and Easy-to-Use iOS Swift Date Picker
Install / Use
/learn @di2pra/D2PDatePickerREADME
D2PDatePicker
<table> <tr> <th><img alt="Screenshot 1" src="https://github.com/di2pra/D2PDatePicker/blob/master/image/screen_1.png" width="300"></th> <th><img alt="Screenshot 1" src="https://github.com/di2pra/D2PDatePicker/blob/master/image/demo.gif" width="300"></th> <th><img alt="Screenshot 2" src="https://github.com/di2pra/D2PDatePicker/blob/master/image/screen_2.png" width="300"></th> </tr> </table>Example
To run the example project, clone the repo, and run pod install from the Example directory first.
Example Code: Programmatical Initialization
import D2PDatePicker
class ViewController: UIViewController {
var datePickerView: D2PDatePicker!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Init DatePickerView
datePickerView = D2PDatePicker(frame: .zero, date: Date())
datePickerView.translatesAutoresizingMaskIntoConstraints = false
// Set the Delegate
datePickerView.delegate = self
self.view.addSubview(datePickerView)
self.view.addConstraints([
NSLayoutConstraint(item: datePickerView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 250),
NSLayoutConstraint(item: datePickerView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 200),
NSLayoutConstraint(item: datePickerView, attribute: .centerX, relatedBy: .equal, toItem: self.view, attribute: .centerX, multiplier: 1, constant: 0),
NSLayoutConstraint(item: datePickerView, attribute: .centerY, relatedBy: .equal, toItem: self.view, attribute: .centerY, multiplier: 1, constant: 0)])
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension ViewController: D2PDatePickerDelegate {
func didChange(toDate date: Date) {
print(date)
}
}
Documentation
All of the methods and properties available for D2PDatePicker are documented below.
Changing the Main Color
The mainColor Property
Use the mainColor property of D2PDatePicker to change the color.
Example usage:
self.datePickerView.mainColor = .red
Delegate
D2PDatePicker uses a delegate to receive date change events. The delegate object must conform to the D2PDatePickerDelete protocol, which is composed of the method:
didChange(toDate date: Date)Tells the delegate that the selected the date get updated.
Requirements
No Requirements
Installation
D2PDatePicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'D2PDatePicker'
Author
Credits
Credit to http://felicegattuso.com/projects/datedropper/ for the inspiration
License
D2PDatePicker is available under the MIT license. See the LICENSE file for more info.
Related Skills
node-connect
351.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
