Inherits from UIView
Declared in TSQCalendarView.h
TSQCalendarView.m

Overview

The TSQCalendarView class displays a monthly calendar in a self-contained scrolling view. It supports any calendar that NSCalendar supports.

The implementation and usage are very similar to UITableView: the app provides reusable cells via a data source and controls behavior via a delegate. See TSQCalendarCell for a cell superclass.

Tasks

Date Setup

Calendar Configuration

Visual Configuration

Properties

calendar

The calendar type to use when displaying.

@property (nonatomic, strong) NSCalendar *calendar

Discussion

If not set, this defaults to [NSCalendar currentCalendar].

Declared In

TSQCalendarView.h

contentInset

The distance from the edges of the view to where the content begins.

@property (nonatomic) UIEdgeInsets contentInset

Discussion

This property is equivalent to the one defined on UIScrollView.

Declared In

TSQCalendarView.h

contentOffset

The point on the calendar where the currently-visible region starts.

@property (nonatomic) CGPoint contentOffset

Discussion

This property is equivalent to the one defined on UIScrollView.

Declared In

TSQCalendarView.h

delegate

The delegate of the calendar view.

@property (nonatomic, weak) id<TSQCalendarViewDelegate> delegate

Discussion

The delegate must adopt the TSQCalendarViewDelegate protocol. The TSQCalendarView class, which does not retain the delegate, invokes each protocol method the delegate implements.

Declared In

TSQCalendarView.h

firstDate

The earliest month the calendar view displays.

@property (nonatomic, strong) NSDate *firstDate

Discussion

Set this property to any NSDate; TSQCalendarView will only look at the month and year. Must be set for the calendar to be useful.

Declared In

TSQCalendarView.h

headerCellClass

The cell class to use for month headers.

@property (nonatomic, strong) Class headerCellClass

Discussion

Since there’s very little configuration to be done for each cell, this can be set as a shortcut to implementing a data source. The class should be a subclass of TSQCalendarMonthHeaderCell or at least implement all of its methods.

Declared In

TSQCalendarView.h

lastDate

The latest month the calendar view displays.

@property (nonatomic, strong) NSDate *lastDate

Discussion

Set this property to any NSDate; TSQCalendarView will only look at the month and year. Must be set for the calendar to be useful.

Declared In

TSQCalendarView.h

pagingEnabled

Whether or not the calendar snaps to begin a month at the top of its bounds.

@property (nonatomic) BOOL pagingEnabled

Discussion

This property is roughly equivalent to the one defined on UIScrollView except the snapping is to months rather than integer multiples of the view’s bounds.

Declared In

TSQCalendarView.h

pinsHeaderToTop

Whether to pin the header to the top of the view.

@property (nonatomic) BOOL pinsHeaderToTop

Discussion

If you’re trying to emulate the built-in calendar app, set this to YES. Default value is NO.

Declared In

TSQCalendarView.h

rowCellClass

The cell class to use for week rows.

@property (nonatomic, strong) Class rowCellClass

Discussion

Since there’s very little configuration to be done for each cell, this can be set as a shortcut to implementing a data source. The class should be a subclass of TSQCalendarRowCell or at least implement all of its methods.

Declared In

TSQCalendarView.h

selectedDate

The currently-selected date on the calendar.

@property (nonatomic, strong) NSDate *selectedDate

Discussion

Set this property to any NSDate; TSQCalendarView will only look at the month, day, and year. You can read and write this property; the delegate method calendarView:didSelectDate: will be called both when a new date is selected from the UI and when this method is called manually.

Declared In

TSQCalendarView.h

Instance Methods

scrollToDate:animated:

Scrolls the receiver until the specified date month is completely visible.

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

Parameters

date

A date that identifies the month that will be visible.

animated

YES if you want to animate the change in position, NO if it should be immediate.

Declared In

TSQCalendarView.h