A clean month view calendar library for iOS. Created in Objective-C, and supports autolayout with iPhone and iPad.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Demo Project
NEXCalendar
License.txt
ReadMe.md
Screenshot.png

ReadMe.md

Summary

NEXCalendar is an Objective-C month view library that works on both iPad and iPhone. For efficiency and speed, the calendar uses a UICollectionView to display dates, instead of manually drawing the entire calendar every time something changes like some other libraries. NEXCalendar also implements a clean design that can be used for highlighting events on any given date using a small dot on the day. Infinite scrolling vertically is supported and several handy delegate methods are provided, as well as lots of customization options.

On the back-end, NEXCalendar uses [NSTimeZone localTimeZone] to determine dates to render, as well as the current date. All delegate and data source methods, as well as public properties, return dates converted to noon local time.

Screenshot

Usage

Setup

Drag all the files from the NEXCalendar folder (NEXCalendar.h, NEXCalendar.m, etc.) into your project.

Use the following function to initialize a new instance of NEXCalendar. This class method returns a calendar view loaded from an XIB file and set up with some initial values. This is the correct way to initialize an instance of NEXCalendar.

+(NEXCalendar *)calendarWithDataSource:(id<NEXCalendarDataSource>)dataSrc delegate:(id<NEXCalendarDelegate>)delegate

You can also open the demo project for examples, and read more about usage and customization below.


Data source

Conform to the protocol <NEXCalendarDataSource> and implement the following function in order to feed data into the calendar for displaying dots on dates:


-(BOOL)nexCalendar:(NEXCalendar *)calendar shouldShowDotForDate:(NSDate *)date

Required. This function is called to determine whether or not to show a cell's badge "dot" for a given date.


Delegation

You can optionally conform to the protocol <NEXCalendarDelegate> and implement the following functions:


-(void)nexCalendar:(NEXCalendar *)calendar scrolledInMonth:(NSDate *)month

Optional. Called any time the calendar scrolls. Frequency is similar to that of a UIScrollView.


-(void)nexCalendar:(NEXCalendar *)calendar endedScrollingWithStart:(NSDate *)startDate end:(NSDate *)endDate

Optional. Called when the calendar stops scrolling and is no longer animating. Provides the first and last visible dates on the calendar.


-(void)nexCalendar:(NEXCalendar *)calendar changedSelectedDate:(NSDate *)date

Optional. Called when a new date is selected on the calendar (typically when the user taps on one).


Other functions

-(NSDate *)dateForPointOnCalendar:(CGPoint)point

Returns an NSDate object for a given CGPoint within the NEXCalendar view's bounds.


-(void)selectDate:(NSDate *)date animated:(BOOL)animated

Used for highlighting a specific date on the calendar. Setting animated to TRUE will scroll the calendar visually, otherwise it will simply snap to that date instantly.


-(void)applyTimeframeWithStart:(NSDate *)start end:(NSDate *)end

Applies a timeframe restriction to the calendar, only allowing the user to scroll between these dates. If non-nil, will round up to the nearest 7 days.


-(void)refresh

Re-renders the calendar. Similar to the reloadData function of a UITableView or UICollectionView.


Customization

@property (nonatomic, assign) BOOL showsMotionHeader

If this is TRUE, a header with the month/year will animate in and out as the user scrolls. Set this to FALSE to hide it. Defaults to TRUE.


@property (nonatomic, strong) UIFont *font

The font used for calendar headers and date labels. The size of the font is ignored, only the font name is implemented.


@property (nonatomic, strong) UIColor *headerColor

The background color of the weekday header.


@property (nonatomic, strong) UIColor *headerTextColor

The text color of the weekday header labels.


@property (nonatomic, strong) UIColor *textColorDefault

The text color of any date that is not today or the selected date on the calendar.


@property (nonatomic, strong) UIColor *textColorSelected

The text color of the selected date on the calendar.


@property (nonatomic, strong) UIColor *textColorToday

The text color of today's date on the calendar.


@property (nonatomic, strong) UIColor *cellColorDefault

The background color of any date that is not today or the selected date on the calendar.


@property (nonatomic, strong) UIColor *cellColorSelected

The background color of the selected date on the calendar.


@property (nonatomic, strong) UIColor *cellColorToday

The background color of today's date on the calendar.


Read-only properties

@property (nonatomic, readonly) int weeksDisplaying

The number of weeks that are visible on the calendar view (the number of rows).


@property (nonatomic, readonly) float headerHeight

The height of the weekday header view of the calendar as currently rendered.


@property (nonatomic, readonly) int cellDimensions

The width/height of any date's cell as currently rendered.


@property (nonatomic, readonly) NSDate *selectedDate

The date currently selected/highlighted on the calendar view.


@property (nonatomic, readonly) NSDate *firstDate

The first date (top left corner) that is visible on the calendar.


@property (nonatomic, readonly) NSDate *lastDate

The last date (bottom right corner) that is at least partially visible on the calendar.


@property (nonatomic, readonly) NSDate *timeframeStart;

The first date that the user can scroll to on the calendar. If non-nil, the view will not scroll before this date


@property (nonatomic, readonly) NSDate *timeframeEnd;

The last date that the user can scroll to on the calendar. If non-nil, the view will not scroll after this date


####Feedback

Feel free to send pull requests or to email us at feedback@nexmachine.com.