Home

Awesome

DateTimePicker

A nicer iOS UI component for picking date and time.

<img src="https://raw.githubusercontent.com/itsmeichigo/DateTimePicker/master/screenshot.jpg" width="280">

Features

To-dos (HELP NEEDED! 🎯)

Requirements

Installation

Using Cocoapod

Just add the following to your podfile

pod 'DateTimePicker'

Using Carthage

From v2.1.0 onward, you can integrate DateTimePicker into your Xcode project using Carthage by specifying it in your Cartfile:

github "itsmeichigo/DateTimePicker" ~> 2.1.0

Run carthage update to build the framework and drag the built DateTimePicker.framework into your Xcode project.

Using Swift Package Manager

From v2.5.0 you can add DateTimePicker to your project via SPM. Paste link to this repo in SPM configuration window and you're good to go.

Manual install

Drag and drop folder Source to your project. Please make sure to update the nib files custom class module to inherit from your current target so that the custom files can be found:

<img width="259" alt="Screen Shot 2020-03-15 at 11 21 31 AM" src="https://user-images.githubusercontent.com/5533851/76695246-5f282d80-66af-11ea-9148-59391c834df5.png"> <img width="258" alt="Screen Shot 2020-03-15 at 11 37 20 AM" src="https://user-images.githubusercontent.com/5533851/76695402-79630b00-66b1-11ea-8d6b-590e85cb4e2e.png"> <img width="256" alt="Screen Shot 2020-03-15 at 11 37 34 AM" src="https://user-images.githubusercontent.com/5533851/76695405-7ec05580-66b1-11ea-874a-3a087d476300.png">

Demo

Navigation to folder named DateTimePickerDemo, run pod install and open the workspace file to play around with DateTimePicker.

Usage

v2.0

Since v2.0 onward, picker view can be created separately and used to add to any view you want. Note: the picker view is built with fixed width and height, so you're not encouraged to manually update it or you will get corrupted UI for the view. If necessary, please only change the y position of the view.

let min = Date().addingTimeInterval(-60 * 60 * 24 * 4)
let max = Date().addingTimeInterval(60 * 60 * 24 * 4)
let picker = DateTimePicker.create(minimumDate: min, maximumDate: max)
picker.frame = CGRect(x: 0, y: 100, width: picker.frame.size.width, height: picker.frame.size.height)
self.view.addSubview(picker)

If you still want the old behavior (show the picker like a modal), you can call show method:

let picker = DateTimePicker()
picker.show()

v1.3 and below

For older versions, the only option is to use the built in show method, which returns an instance of DateTimePicker and also show the picker like a modal on top window. The picker can be dismissed when Cancel button is tapped.

let picker = DateTimePicker.show()

Customization

There are many options to customize picker for your own desire:

Contributing

Contributions for bug fixing or improvements are welcome. Feel free to submit a pull request.

Licence

DateTimePicker is available under the MIT license. See the LICENSE file for more info.