Skip to content

Latest commit

 

History

History

THCalendarDatePicker

Pod Version Pod Platform Pod License

This control is based on the datepicker-ios control combined with the KNSemiModalViewController.

The original controller was not aware of orientation changes and was missing some customization features that I needed for my project, so I decided to rewrite part of the controller to fit to my needs

Screenshots

iPhone Portrait iPhone Landscape

Installation

CocoaPods

Install with CocoaPods by adding the following to your Podfile:

platform :ios, '6.1'
pod 'THCalendarDatePicker', '~> 1.0.0'

Note: We follow http://semver.org for versioning the public API.

Manually

Or copy the THCalendarDatePicker/ directory from this repo into your project.

Usage

This is a sample initialization taken from the ExampleProject.

- (IBAction)touchedButton:(id)sender {
    if(!self.datePicker)
        self.datePicker = [THDatePickerViewController datePicker];
    self.datePicker.date = self.curDate;
    self.datePicker.delegate = self;
    [self.datePicker setAllowClearDate:NO];
    [self.datePicker setClearAsToday:YES];
    [self.datePicker setAutoCloseOnSelectDate:YES];
    [self.datePicker setAllowSelectionOfSelectedDate:YES];
    [self.datePicker setDisableHistorySelection:YES];
    [self.datePicker setDisableFutureSelection:NO];
    [self.datePicker setSelectedBackgroundColor:[UIColor colorWithRed:125/255.0 green:208/255.0 blue:0/255.0 alpha:1.0]];
    [self.datePicker setCurrentDateColor:[UIColor colorWithRed:242/255.0 green:121/255.0 blue:53/255.0 alpha:1.0]];

    [self.datePicker setDateHasItemsCallback:^BOOL(NSDate *date) {
     int tmp = (arc4random() % 30)+1;
     if(tmp % 5 == 0)
     return YES;
     return NO;
     }];
    //[self.datePicker slideUpInView:self.view withModalColor:[UIColor lightGrayColor]];
    [self presentSemiViewController:self.datePicker withOptions:@{
                                                                  KNSemiModalOptionKeys.pushParentBack    : @(NO),
                                                                  KNSemiModalOptionKeys.animationDuration : @(1.0),
                                                                  KNSemiModalOptionKeys.shadowOpacity     : @(0.3),
                                                                  }];
}

Features

V1.0.X

  • Fixed issue #23

V0.2.X

V0.1.X

  • Bugfix (Now it's taking the default starting day for the locale; but not the custom setting "Week starts on")
  • Configurable if it should show future entries
  • Select a Date from Calendar
  • Awareness of the setting 4 the first weekday
  • Configurable Colors
  • Configurable if it should be allowed to clear the selection
  • Configurable if it should close on selection or not

Future

  • reduce size of control if "hasItemCallback" is not used/disabled

#Contributions

...are really welcome. If you have an idea just fork the library change it and if its useful for others and not affecting the functionality of the library for other users I'll insert it

###Contributors

License

Source code of this project is available under the standard MIT license. Please see the license file.