Elegant and Easy-to-Use iOS Swift Date Picker

Overview

D2PDatePicker

CI Status Version License Platform

   
Screenshot 1 Screenshot 1 Screenshot 2

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

Di2pra LinkedIn

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.

You might also like...
An iOS picker view to serve all your
An iOS picker view to serve all your "picking" needs

Mandoline The PickerView is a UICollectionView that provides a smooth "picking" interface. In order to get the most out of it, a consuming view contro

A country picker view controller for iOS
A country picker view controller for iOS

Planet A country picker view controller for iOS. Installation CocoaPods You can use CocoaPods to install Planet by adding it to your Podfile: platform

MICountryPicker is a country picker controller for iOS8+ with an option to search.
MICountryPicker is a country picker controller for iOS8+ with an option to search.

MICountryPicker MICountryPicker is a country picker controller for iOS8+ with an option to search. The list of countries is based on the ISO 3166 coun

A simple, customizable Country picker for picking country or dialing code. ๐Ÿ‡ฎ๐Ÿ‡ณ ๐Ÿ‡ฏ๐Ÿ‡ต ๐Ÿ‡ฐ๐Ÿ‡ท ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡จ๐Ÿ‡ณ ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ซ๐Ÿ‡ท ๐Ÿ‡ช๐Ÿ‡ธ ๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ‡ท๐Ÿ‡บ ๐Ÿ‡ฌ๐Ÿ‡ง
A drop in single image picker.

PHSingleImagePicker A low memory, single image picker wrapper that provide a significant smaller file size while also preserve high image quality. Int

React-native-place-picker: Pick any place with single click ๐Ÿš€
React-native-place-picker: Pick any place with single click ๐Ÿš€

React-native-place-picker: Pick any place with single click ๐Ÿš€

A SwiftUI implementation of a picker that also allows direct input.
A SwiftUI implementation of a picker that also allows direct input.

ComboPicker ComboPicker is a SwiftUI view that allows users to input a value by selecting from a predefined set or by typing a custom one. Installatio

Elegant manager to easily deal with UIPickerView
Elegant manager to easily deal with UIPickerView

PickL PickL is an elegant manager to easily deal with UIPickerView. You don't have to implement a logic for UIPickerViewDataSource and UIPickerViewDel

A ฮผlibrary in Swift containing all the countries with their localized name, ISO code, phone code, country code, flag image and emoji.

CountryKit CountryKit A ฮผlibrary in Swift containing all the countries with their localized name, ISO code, phone code, country code, flag image and e

Comments
  • How to resize and locate in concrete position screen?

    How to resize and locate in concrete position screen?

    Could you tell me how to indicate the frame where the calendar would be drawn and if is it possible to resize the calendar according to the frame where it will be shown.

    Thank you in advance

    opened by dhonti89 0
  • How can I change Date, Month, Year on swipe?

    How can I change Date, Month, Year on swipe?

    I want to change year by swipe instead of button click. is there any way to do this? because current year is 2018 and some 1 want to select 1980 than it's too long.

    Thanks in Advance.

    opened by StellarKuldeep 0
  • add horizontal direction for example

    add horizontal direction for example

    Hi, I'm japanese engineer. Thanks beautiful date picker. I'm trying add Horizontal Direction.

    Sorry, I don't know how to fix library. I fixed example. For now, I'd like you to check if the lateral movement is a good plan.

    Thanks.

    opened by senseiphoneX 1
Owner
Pradheep Rajendirane
Pradheep Rajendirane
Date picker dialog for iOS

DatePickerDialog 4.0 - iOS - Swift DatePickerDialog is an iOS drop-in classe that displays an UIDatePicker within an UIAlertView. Requirements DatePic

Squimer 535 Dec 17, 2022
A SwiftUI List Picker to replace system Picker in List

BetterListPicker An alternative customizable list picker in order to replace built-in non customizable Picker when we write settings view codes. Demo

Jinya 1 Apr 11, 2022
LocationPicker - A ready for use and fully customizable location picker for your app

LocationPicker A ready for use and fully customizable location picker for your app. Features Installation Cocoapods Carthage Swift Package Manager Qui

Zhuoran 397 Nov 16, 2022
FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

null 10 Dec 11, 2022
:date: UIDatePicker modally presented with iOS 7 custom transitions.

AIDatePickerController Installation Manually Download and drop /AIDatePickerControllerfolder in your project. Congratulations! Usage // Create a date

Ali Karagoz 90 Sep 23, 2022
Multi-picker for iOS and Mac available in SwiftUI

Multi-picker for iOS and Mac available in Swift UI

1amageek 5 Jul 12, 2022
iOS/macOS media picker for importing images and videos in SwiftUI

iOS/macOS media picker for importing images and videos in SwiftUI.

Mobile Development Club 13 Dec 30, 2022
๐ŸŽฏ Swift country and phone code Picker

CountryPicker Picker code Swift 3 / 4 / 5. Example To run the example project, clone the repo, and run pod install from the Example directory first. U

null 207 Dec 22, 2022
A simple yet customizable horizontal and vertical picker view

WheelPicker A simple yet customizable horizontal and vertical picker view Features Vertical or Horizontal picker Image or Text data Configure UILabel

Mind Studios 74 Sep 26, 2022
a picker view shown as a popup for iOS in Objective-C

CZPicker Demo Change Log 3 most recent changes are listed here. Full change logs v0.4.3 - 2016-08-12 Added - (void)czpickerViewWillDisplay:(CZPickerVi

Chen Zeyu 527 Oct 2, 2022