Go to file
DingWenchao 566b504bee Update Readme
Update Readme
2015-07-01 14:05:36 +08:00
Example Update Readme 2015-07-01 14:05:36 +08:00
Pod Update example 2015-07-01 13:59:28 +08:00
.gitignore Initial commit 2015-02-13 22:10:59 +08:00
FSCalendar.podspec Create branch 0.9.0 2015-06-29 17:53:08 +08:00
LICENSE Initial commit 2015-02-13 22:10:59 +08:00
README.md Update Readme 2015-07-01 14:05:36 +08:00

README.md

fscalendar

Version License Platform

Installation

  • Using cocoapods:pod 'FSCalendar'
  • Manually: Unzip downloaded zip file, drag all files under FSCalendar-master/Pod/Classes to your project, make sure copy items if needed is checked.
#import "FSCalendar.h"

Setup

  1. Drag an UIView object to ViewController Scene, change the Custom Class to FSCalendar
  2. After adjust the position and frame, link the dataSource and delegate to the ViewController
  3. Implement FSCalendarDataSource and FSCalendarDelegate in ViewController.m

Use code

@property (weak , nonatomic) FSCalendar *calendar;

// In loadView or viewDidLoad
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
calendar.dataSource = self;
calendar.delegate = self;
[self.view addSubview:calendar];
self.calendar = calendar;

Or swift

private weak var calendar: FSCalendar!

// In loadView or viewDidLoad
let calendar = FSCalendar(frame: CGRect(x: 0, y: 0, width: 320, height: 300))
calendar.dataSource = self
calendar.delegate = self
view.addSubview(calendar)
self.calendar = calendar

More usage

If you want FSCalendar to scroll vertically (default horizontally)

  • Objective - c
_calendar.flow = FSCalendarFlowVertical;
  • Swift
calendar.flow = .Vertical 

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

_calendar.firstWeekday = 2; 

If you wanna change the date format for header

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

If you wanna change colors

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

What if you wanna hide this?

_calendar.appearance.headerMinimumDissolvedAlpha = 0.0;

What if you wanna show this without alpha?

_calendar.appearance.headerMinimumDissolvedAlpha = 1.0;

If you want FSCalendar to show subtitle for each day

// FSCalendarDataSource
- (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date
{
    return yourSubtitle;
}

If you want FSCalendar to show event dot for some days

// FSCalendarDataSource
- (BOOL)calendar:(FSCalendar *)calendar hasEventForDate:(NSDate *)date
{
    return shouldShowEventDot;
}

If you want FSCalendar to show an image for some days

// FSCalendarDataSource
- (UIImage *)calendar:(FSCalendar *)calendar imageForDate:(NSDate *)date
{
    return anyImage;
}

If you want set a boundary for FSCalendar

// FSCalendarDataSource
- (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar
{
    return [NSDate fs_dateWithYear:2015 month:1 day:1];
}

- (NSDate *)maximumDateForCalendar:(FSCalendar *)calendar
{
    return [NSDate fs_dateWithYear:2015 month:10 day:31];
}

If you want to do something when a date is selected

// FSCalendarDelegate
- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date
{
    // Do something
}

If you don't want some date to be selected

// FSCalendarDelegate
- (BOOL)calendar:(FSCalendar *)calendar shouldSelectDate:(NSDate *)date
{
    if ([date shouldNotBeSelected]) {
        return NO;
    }
    return YES;
}

If you need to do something when the month changes

- (void)calendarCurrentMonthDidChange:(FSCalendar *)calendar
{
    // Do something
}

Requirements

ios 7.0

Compatibility

FSCalendar can be used on iPad, see the demo for details.

Known issues

  1. The title size changed as we change frame size of FSCalendar: Automatically adjusting font size based on frame size is default behavior of FSCalendadr, to disable it:
_calendar.appearance.autoAdjustTitleSize = NO; 
_calendar.appearance.titleFont = otherTitleFont;
_calendar.appearance.subtitleFont = otherSubtitleFont;

titleFont and subtitleFont would not take any effect if autoAdjustTitleSize value is YES

  1. What if I don't need the today circle?
_calendar.appearance.todayColor = [UIColor clearColor];
_calendar.appearance.titleTodayColor = _calendar.appearance.titleDefaultColor;
_calendar.appearance.subtitleTodayColor = _calendar.appearance.subtitleDefaultColor;

License

FSCalendar is available under the MIT license. See the LICENSE file for more info.

Support

  • If FSCalendar cannot meet your requirment, tell me in issues or send your pull requests
  • If you like this control and use it in your app, submit your app's link address here.It would be a great support for me.

Contact

  • email: f33chobits@gmail.com
  • skype: wenchao.ding

Donate