Skip to content

s1m-0n/NDCollapsiveDatePicker

Repository files navigation

NDCollapsiveDatePicker

[![CI Status](http://img.shields.io/travis/Simon Wicha/NDCollapsiveDatePicker.svg?style=flat)](https://travis-ci.org/Simon Wicha/NDCollapsiveDatePicker) Version License Platform

Installation

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

pod 'NDCollapsiveDatePicker'

Usage

To run the example project, clone the repo, and run pod install from the NDCollapsiveDateViewDemo directory first.

Add delegate to protocol into your .h

#import <NDCollapsiveDatePicker/NDCollapsiveDateView.h>

@interface NDViewController : UIViewController <NDCollapsiveDateViewDelegate>

Use one of two init methods:

NDCollapsiveDateView collapsiveDateView = [[NDCollapsiveDateView alloc] initWithFrame:frame title:@"Date" andImage:[UIImage imageNamed:@"calendar"]];
[collapsiveDateView setShown:200.f andHiddenHeight:50];

Or use combined init method:

NDCollapsiveDateView collapsiveDateView = [[NDCollapsiveDateView alloc] initWithFrame:frame title:@"Date" andImage:UIImage imageNamed:@"calendar" hiddenHeight:50 andShownHeight:200.f];

Set delegate:

collapsiveDateView.delegate = self;

include delegate method:

-(void)datePickerViewDidCollapse:(NDCollapsiveDatePickerView *)datePickerView

Example how to get the selected date from NDCollapsiveDateView:

-(void)datePickerViewDidCollapse:(NDCollapsiveDatePickerView *)datePickerView {
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"dd-MM-yyyy"];
    NSString *stringDate = [dateFormatter stringFromDate:datePickerView.date];
    NSLog(@"selected date: %@",stringDate);
}

Feel free to customize the NDCollapsiveDateView

collapsiveDateView.backgroundColor = [UIColor whiteColor];
collapsiveDateView.layer.borderColor = [[UIColor blackColor] CGColor];
...

Screenshot

Animated gif of working NDCollapsiveDateView

Author

Simon Wicha | simon.wicha@nomis-development.net

License

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