Latest 1.0.1
Homepage https://github.com/mtzaquia/MTZExpirationDatePicker
License MIT
Platforms ios 9.0
Authors

The MTZExpirationDatePicker is a simple component that subclass UIPickerView and provides an easy and drop-in way to use it with your project. It also allows the setup of a minimum and maximum date.

MTZExpirationDatePicker

Installation

Manual

Simply drop the files MTZExpirationDatePicker.h and MTZExpirationDatePicker.m to your project and import wherever needed.

CocoaPods

You can also declare the following on your Podfile:

pod 'MTZExpirationDatePicker', '~> 1.0.1'

Sample Usage

Using the picker is relatively straight forward. Most commonly as an inputView as such:

self.expirationDatePicker = [[MTZExpirationDatePicker alloc] init];
self.expirationDatePicker.datePickerDelegate = self; // Needed as UIPickerView doesn't inherited from UIControl.
if (minimumDate) {
    self.expirationDatePicker.minimumDate = minimumDate;
}

if (maximumDate) {
    self.expirationDatePicker.maximumDate = maximumDate;
}

[self.textField setInputView:self.expirationDatePicker];

Then on the delegate just implement the method to know whenever the date has been changed:

#pragma mark - MTZDatePickerDelegate
- (void)datePickerDidChangeDate:(MTZExpirationDatePicker *)datePicker {
    self.textField.text = [self.dateFormatter stringFromDate:datePicker.date];
}

or just access the property date whenever needed.

self.textField.text = [self.dateFormatter stringFromDate:self.expirationDatePicker.date];

You can also set a date manually, and it will respect the minimum and maximum dates, if any:

[self.expirationDatePicker setDate:[NSDate date] animated:YES];

If you don’t fancy the separator, just disable it:

self.expirationDatePicker.showsSeparator = NO;

That’s pretty much it. Enjoy! :)

License

MTZExpirationDatePicker is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "MTZExpirationDatePicker",
    "version": "1.0.1",
    "summary": "A simple UIPickerView subclass optimised for expiration date handling.",
    "description": "The MTZExpirationDatePicker is a simple component that subclass UIPickerView and provides an easy and drop-in way to use it with your project. It also allows the setup of a minimum and maximum date.",
    "homepage": "https://github.com/mtzaquia/MTZExpirationDatePicker",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Mauricio Tremea Zaquia": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mtzaquia/MTZExpirationDatePicker.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "*.{h,m}"
}

Pin It on Pinterest

Share This