If you want FSCalendar
to scroll vertically
_calendar.scrollDirection = FSCalendarScrollDirectionVertical;
calendar. scrollDirection = . Vertical
If you want FSCalendar
to scroll horizontally (Default)
_calendar.scrollDirection = FSCalendarScrollDirectionHorizontal; // By default
calendar. scrollDirection = . Horizontal
_calendar.scope = FSCalendarScopeWeek;
_calendar.scope = FSCalendarScopeMonth; // By default
To select more than one date
_calendar.allowsMultipleSelection = YES ;
If you want FSCalendar
to use Monday
as the first column (or any other weekday)
_calendar.firstWeekday = 2 ;
The date format of header can be customized
_calendar.appearance.headerDateFormat = @" MMM yy" ;
You can define the appearance
_calendar.appearance.weekdayTextColor = [UIColor redColor ];
_calendar.appearance.headerTitleColor = [UIColor redColor ];
_calendar.appearance.eventColor = [UIColor greenColor ];
_calendar.appearance.selectionColor = [UIColor blueColor ];
_calendar.appearance.todayColor = [UIColor orangeColor ];
_calendar.appearance.todaySelectionColor = [UIColor blackColor ];
The day shape doesn't have to be a circle
_calendar.appearance.cellStyle = FSCalendarCellStyleRectangle;
calendar. appearance. cellStyle = . Rectangle
FSCalendar
can show subtitle for each day
// FSCalendarDataSource
- (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date
{
return yourSubtitle;
}
// FSCalendarDataSource
func calendar( calendar: FSCalendar ! , subtitleForDate date: NSDate ! ) -> String ! {
return yourSubtitle
}
And event dot for some days
// FSCalendarDataSource
- (BOOL )calendar:(FSCalendar *)calendar hasEventForDate:(NSDate *)date
{
return shouldShowEventDot;
}
// FSCalendarDataSource
func calendar( calendar: FSCalendar ! , hasEventForDate date: NSDate ! ) -> Bool {
return shouldShowEventDot
}
// FSCalendarDataSource
- (UIImage *)calendar:(FSCalendar *)calendar imageForDate:(NSDate *)date
{
return anyImage;
}
// FSCalendarDataSource
func calendar( calendar: FSCalendar ! , imageForDate date: NSDate ! ) -> UIImage ! {
return anyImage
}
There are left and right boundaries
// FSCalendarDataSource
- (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar
{
return yourMinimumDate;
}
- (NSDate *)maximumDateForCalendar:(FSCalendar *)calendar
{
return yourMaximumDate;
}
You can do something when a date is selected
// FSCalendarDelegate
- (void )calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date
{
// Do something
}
// FSCalendarDelegate
func calendar( calendar: FSCalendar ! , didSelectDate date: NSDate ! ) {
}
You can prevent it from being selected
// FSCalendarDelegate
- (BOOL )calendar:(FSCalendar *)calendar shouldSelectDate:(NSDate *)date
{
if ([dateShouldNotBeSelected]) {
return NO ;
}
return YES ;
}
func calendar( calendar: FSCalendar ! , shouldSelectDate date: NSDate ! ) -> Bool {
if dateShouldNotBeSelected {
return false
}
return true
}
You will get notified when FSCalendar
changes the month
- (void )calendarCurrentMonthDidChange:(FSCalendar *)calendar
{
// Do something
}
func calendarCurrentMonthDidChange( calendar: FSCalendar ! ) {
// Do something
}
fakeSubtitles
and fakedSelectedDay
is only used for preview in Interface Builder
What if I don't need the today
circle?
_calendar.today = nil ;
_calendar.currentPage = [NSDate date ];
Can we hide this?
_calendar.appearance.headerMinimumDissolvedAlpha = 0.0 ;