Latest 1.0.1
Homepage https://github.com/FreshworksStudio/DatePicker
License MIT
Platforms ios 10.0
Dependencies Extended
Authors

CI Status
Version
License
Platform

Alt Text

Installation

DatePicker is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'DatePicker', '1.0.0'

Quick Usage

1) Import the library

import UIKit
import DatePicker

class ViewController: UIViewController {
}

2) Setup

  • Picker between today and 100 years from now:
let datePicker = DatePicker()
datePickersetup { (selected, date) in
    if selected, let selectedDate = date {
        print("(selectedDate)"
    } else {
        print("cancelled")
    }
}
  • Picker with minimum and maximum dates:
let datePicker = DatePicker()
datePicker.setup(min: minDate, max: maxDate) { (selected, date) in
    if selected, let selectedDate = date {
        print("(selectedDate)"
    } else {
        print("cancelled")
    }
}

You could also use DatePickerHelper’s functions to help generate dates:

let minDate = DatePickerHelper.shared.dateFrom(day: 18, month: 08, year: 1990)
let maxDate = DatePickerHelper.shared.dateFrom(day: 18, month: 08, year: 2020)
  • Yearless Picker: select and return day and month integers independent of year.
let datePicker = DatePicker()
datePicker.setupYearless { (selected, month, day) in
    if selected, let day = day, let month = month {
        print("selected (month) (day)")
        // You can also use DatePickerHelper's functions:
        // DatePickerHelper.shared.month(number: Int) will return the month string name
        print("selected DatePickerHelper.shared.month(number: month) (day)")
    } else {
        print("cancelled")
    }
}

Alt Text

3) Display

  • Screen Center:

    datePicker.display(in: self)
  • Or as Popover (for iPads):
    datePicker.displayPopOver(on: button, in: self)

Alt Text

Credit

Alt Text

License

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

Latest podspec

{
    "name": "DatePicker",
    "version": "1.0.1",
    "summary": "Date Picker for iOS",
    "description": "A simple, elegant Date Picker library for iOS",
    "homepage": "https://github.com/FreshworksStudio/DatePicker",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "amirshayegh": "[email protected]"
    },
    "source": {
        "git": "https://github.com/FreshworksStudio/DatePicker.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "DatePicker/Classes/**/*.{swift}",
    "resource_bundles": {
        "DatePicker": [
            "DatePicker/Classes/**/*.{storyboard,xib}"
        ]
    },
    "dependencies": {
        "Extended": [
            "~> 1.0.4"
        ]
    }
}

Pin It on Pinterest

Share This