GithubHelp home page GithubHelp logo

toygift / d2pdatepicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from di2pra/d2pdatepicker

0.0 1.0 0.0 965 KB

Elegant and Easy-to-Use iOS Swift Date Picker

License: MIT License

Ruby 6.04% Swift 93.96%

d2pdatepicker's Introduction

D2PDatePicker

CI Status Version License Platform

   
Screenshot 1 Screenshot 1Screenshot 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.

d2pdatepicker's People

Contributors

di2pra avatar toygift avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.