Coder Social home page Coder Social logo

srmonthpicker's Introduction

SRMonthPicker

Build Status CocoaPods Platform CocoaPods Version Carthage compatible

SRMonthPicker is like UIDatePicker, but without the days. As the name says, it's a fully localised month picker that allows the user to choose a month and a year. Perfect for entering credit card expiry dates or just when you don't need a day component. It's meant to mimic the look, feel & behaviour of 2 native UI elements on iOS:

  • A month picker that appears for an <input type="month" /> element on iOS Safari, sadly not exposed via any native control or a setting on UIDatePicker.
  • A UIDatePicker set to Date-only mode, but without the day element.

Screenshot

SRMonthPicker has been tested on iOS 7 and above. It should also work on iOS 5-6, but this hasn't been tested for a while. It is licensed under the terms of the MIT License.

Including in your project

The easiest way by far of including this project is to use CocoaPods. Once you've got that up & running for your project, simply add the dependency to your Podfile:

platform :ios, "5.0"

pod "SRMonthPicker"

Then run pod install to install the dependencies.

Alternatively, if you're targeting iOS8 or above, SRMonthPicker is also compatible with Carthage - simply add this to your Cartfile:

github "SimonRice/SRMonthPicker"

If you're not using a dependency manager, simply clone this project as a submodule or download the classes in the SRMonthPicker directory, and include them in your project. Bear in mind this library uses ARC, so you should create a Static Library if your project doesn't.

If you're using QuickDialog, you may be interested in QMonthElement, which integrates one of these month pickers into your QuickDialog forms. Integrations for other form frameworks, such as XLForm and FXForms, are in the works as well.

Usage

For Interface Builder (including Storyboard), simply drag out a UIPickerView in Interface Builder. Under the Assistant Editor, set the class of the picker to SRMonthPicker. If you're building your interfaces by code, it's simply a case of initialising an SRMonthPicker instance & adding a subview. In XCode 6 and above, you will also have the option of modifying some of the month picker's properties straight from the attributes inspector on Interface Builder.

You have properties to show the year first, along with the setting (& getting) the selected date, plus the maximum & minimum years.

As of version 0.2.5, there is a SRMonthPickerDelegate. This provides 2 optional methods:

  • - (void)monthPickerWillChangeDate:(SRMonthPicker *)monthPicker
  • - (void)monthPickerDidChangeDate:(SRMonthPicker *)monthPicker

Because the delegate property is used internally, you'll need to assign your delegate to the month picker's monthPickerDelegate property.

A simple example project showing off many of the features can be seen in the Example folder. In addition, the header files are fully documented in AppleDoc format - thanks to CocoaDocs, you can see the full documentation in your browser.

Contributions

As everyone says, GitHub is about social coding - I didn't just choose to use it because of my love of git as a version control system. Please do chip in & help make this an even better project, or even file in an issue if you see anything not working right.

License

As stated further up on this page, usage is provided under the MIT License. See the LICENSE file or any class header for the full details.

srmonthpicker's People

Contributors

simonrice avatar rolandasrazma avatar agrigg avatar tangtao avatar

Watchers

Leo 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.