Yet another calendar component for iOS. Compatible with iOS 4.0 (iPhone & iPad) and higher. UI is inspired by
Switch branches/tags
Nothing to show
Pull request Compare This branch is 61 commits behind kovpas:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

PMCalendar v0.1

Yet another calendar component for iOS. Compatible with iOS 4.0 (iPhone & iPad) and higher.

UI is inspired by ocrickard's OCCalendarController. It's quite good component, but doesn't have some useful features which I wanted to see. Unfortunately OCCalendarController very hard to maintain, so I decided to create my own implementation.

PMCalendar supports selection of multiple dates within one or several months, appears as a popover (if you used UIPopoverController before, you'll find PMCalendar management very similar), supports orientation changes and does not require any third party frameworks.

It's definitely not bug-free, so if you're going to use PMCalendar in production, please test it hard ;)


Screenshot 1  Screenshot 2

Screenshot 3


  • Add PMCalendar directory to your Xcode project.

  • #import "PMCalendar.h"

  • Create instance of PMCalendarController with wanted size:

     PMCalendarController *calendarController = [[PMCalendarController alloc] initWithSize:CGSizeMake(300, 200)];
  • Or use default:

     PMCalendarController *calendarController = [[PMCalendarController alloc] init];
  • Implement PMCalendarControllerDelegate methods to be aware of controller's state change:

     - (BOOL)calendarControllerShouldDismissCalendar:(PMCalendarController *)calendarController;
     - (void)calendarControllerDidDismissCalendar:(PMCalendarController *)calendarController;
     - (void)calendarController:(PMCalendarController *)calendarController didChangePeriod:(PMPeriod *)newPeriod;
  • Don't forget to assign delegate!

     calendarController.delegate = self;
  • Present calendarController from a view (i.e. UIButton), so calendar could position itself during rotation:

      [calendarController presentCalendarFromView:pressedButton
                         permittedArrowDirections:PMCalendarArrowDirectionUp | PMCalendarArrowDirectionLeft
  • Or CGRect:

      [calendarController presentCalendarFromRect:CGRectMake(100, 100, 10, 10)
                         permittedArrowDirections:PMCalendarArrowDirectionUp | PMCalendarArrowDirectionLeft
  • Dismiss it:

      [calendarController dismissAnimated:YES];


@interface PMPeriod : NSObject

@property (nonatomic, strong) NSDate *startDate;
@property (nonatomic, strong) NSDate *endDate;

 * Creates new period with same startDate and endDate
+ (id) oneDayPeriodWithDate:(NSDate *) date;

+ (id) periodWithStartDate:(NSDate *) startDate endDate:(NSDate *) endDate;

- (NSInteger) lengthInDays;

 * Creates new period from self with proper order of startDate and endDate.
- (PMPeriod *) normalizedPeriod;


Implemented properties

@property (nonatomic, assign) id<PMCalendarControllerDelegate> delegate;

Selected period

@property (nonatomic, strong) PMPeriod *period;

TBI! Period allowed for selection

@property (nonatomic, strong) PMPeriod *allowedPeriod;

Monday is a first day of week. If set to NO then Sunday is a first day

@property (nonatomic, assign, getter = isMondayFirstDayOfWeek) BOOL mondayFirstDayOfWeek;

If NO, only one date can be selected. Otherwise, user can pan to select period

@property (nonatomic, assign) BOOL allowsPeriodSelection;

If YES, user can long press on arrow to iterate through years (single tap iterates through months)

@property (nonatomic, assign) BOOL allowsLongPressYearChange;

Direction of the arrow (similar to UIPopoverController's arrowDirection)

@property (nonatomic, readonly) UIPopoverArrowDirection arrowDirection;

Size of a calendar controller

@property (nonatomic, assign) CGSize size;

Themes (pre-alpha! :))

You can play around with themes by enabling MIMIC_APPLE_THEME define in PMCalendarDemo-Prefix.pch.

I'll add documentation as soon as the feature is ready.

By setting up custom theme you can get something like this:

Apple calendar theme 1 Apple calendar theme 2