Giter Club home page Giter Club logo

xkdatepickerview's Introduction

XKDatePickerView

A simple date picker written in Swift, that has two wheels for year selection and an era picker. Supports Gregorian calender only by now.

alt tag

Features:

  • Year, Month, Century, Subcentury and Era picker wheels
  • 'Infinite' scrolling for Year, Month, Century, Subcentury and Era
  • Minimum and maximum year customization in range from 9999 DCE to 9999 CE
  • Date validation (incl. vs maximum and minimum date)
  • Different color for valid / non-valid date font

Getting Started

Just copy XKDatePickerView.swift to your project. UIPickerViewDataSource and UIPickerViewDelegate protocols are already implemented in AXDatePickerView itself, so don't implement them for axDatePickeView object, Add conformance to XKDatePickerViewDelegate instead. Example:

class ViewController: UIViewController, XKDatePickerViewDelegate {

override func viewDidLoad() {
        super.viewDidLoad()
        xkDatePicker.xkDatePickerDelegate = self
        }

Callback

Implement XKDatePickerViewDelegate function to recieve selected date:

func axDatePickerDateChangedWith(date: Date) {
        // Your code here to handle date
    }

Customization

Make outlet for AXDatePicker object in your controller.

@IBOutlet weak var xkDatePicker: XKDatePickerView!

To select date implement xkDatePickerDateChangedWith function:

func xkDatePickerDateChangedWith(date: Date) {
        // Your code here to handle the date
    }

To change minimum and maximum year set corresponing class property:

let minYear: Int = -4000
xkDatePicker.minimumYear = minYear

let maxYear: Int = 5500
xkDatePicker.maximumYear = maxYear

New dates will be handled automatically at runtime. Keep in mind, that maximum date should be greater than minimum date, otherwise a fatalError will be thrown.

Color for valid and invalid dates use validDateFontColor and invalidDateFontColor properties (handled automatically at runtime):

let balack = UIColor.black()
xkDatePicker.validDateFontColor = balack

let red = UIColor.red()
xkDatePicker.invalidDateFontColor = red

Contributing

Feel free to contribute!

License

This project is licensed under the MIT License - see the LICENSE file for details

xkdatepickerview's People

Contributors

xankraegor avatar

Watchers

 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.