Skip to content

Latest commit

 

History

History
285 lines (201 loc) · 5.84 KB

MOREUSAGE.md

File metadata and controls

285 lines (201 loc) · 5.84 KB

More usage

If you want FSCalendar to scroll vertically

  • Objective - c
_calendar.scrollDirection = FSCalendarScrollDirectionVertical;
  • Swift
calendar.scrollDirection = .Vertical 

fscalendar-vertical

If you want FSCalendar to scroll horizontally (Default)

  • Objective - c
_calendar.scrollDirection = FSCalendarScrollDirectionHorizontal; // By default
  • Swift
calendar.scrollDirection = .Horizontal 

fscalendar-horizontal

For week mode

  • Objective - c
_calendar.scope = FSCalendarScopeWeek;
  • Swift
calendar.scope = .Week 

For month mode

  • Objective - c
_calendar.scope = FSCalendarScopeMonth; // By default
  • Swift
calendar.scope = .Month 

fscalendarscope

To select more than one date

_calendar.allowsMultipleSelection = YES;

fscalendar-mulipleselection

If you want FSCalendar to use Monday as the first column (or any other weekday)

_calendar.firstWeekday = 2; 

fscalendar---monday

The date format of header can be customized

_calendar.appearance.headerDateFormat = @"MMM yy";

fscalendar---headerformat

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];

fscalendar---colors

The day shape doesn't have to be a circle

  • Objective - c
_calendar.appearance.cellStyle = FSCalendarCellStyleRectangle;
  • Swift
calendar.appearance.cellStyle = .Rectangle

fscalendar---rectangle

FSCalendar can show subtitle for each day

  • Objective - c
// FSCalendarDataSource
- (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date
{
    return yourSubtitle;
}
  • Swift
// FSCalendarDataSource
func calendar(calendar: FSCalendar!, subtitleForDate date: NSDate!) -> String! {
    return yourSubtitle
}

fscalendar---subtitle2
fscalendar---subtitle1

And event dot for some days

  • Objective - c
// FSCalendarDataSource
- (BOOL)calendar:(FSCalendar *)calendar hasEventForDate:(NSDate *)date
{
    return shouldShowEventDot;
}
  • Swift
// FSCalendarDataSource
func calendar(calendar: FSCalendar!, hasEventForDate date: NSDate!) -> Bool {
    return shouldShowEventDot
}

Or image for some days

  • Objective - c
// FSCalendarDataSource
- (UIImage *)calendar:(FSCalendar *)calendar imageForDate:(NSDate *)date
{
    return anyImage;
}
  • Swift
// FSCalendarDataSource
func calendar(calendar: FSCalendar!, imageForDate date: NSDate!) -> UIImage! {
    return anyImage
}

fscalendar---image

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

  • Objective - c
// FSCalendarDelegate
- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date
{
    // Do something
}
  • Swift
// FSCalendarDelegate
func calendar(calendar: FSCalendar!, didSelectDate date: NSDate!) {
    
}

You can prevent it from being selected

  • Objective - c
// FSCalendarDelegate
- (BOOL)calendar:(FSCalendar *)calendar shouldSelectDate:(NSDate *)date
{
    if ([dateShouldNotBeSelected]) {
        return NO;
    }
    return YES;
}
  • Swift
func calendar(calendar: FSCalendar!, shouldSelectDate date: NSDate!) -> Bool {
    if dateShouldNotBeSelected {
        return false
    }
    return true
}

You will get notified when FSCalendar changes the month

  • Objective - c
- (void)calendarCurrentMonthDidChange:(FSCalendar *)calendar
{
    // Do something
}
  • Swift
func calendarCurrentMonthDidChange(calendar: FSCalendar!) {
    // Do something
}
  • fakeSubtitles and fakedSelectedDay is only used for preview in Interface Builder

Known issues

  • What if I don't need the today circle?
_calendar.today = nil;
_calendar.currentPage = [NSDate date];
  • Can we hide this? fscalendar---headeralpha
_calendar.appearance.headerMinimumDissolvedAlpha = 0.0;