- Using cocoapods:
pod 'FSCalendar'
- Manually: Unzip downloaded zip file, drag all files under
FSCalendar-master/Pod/Classes
to your project, make surecopy items if needed
is checked.
#import "FSCalendar.h"
- Drag an UIView object to ViewController Scene, change the
Custom Class
toFSCalendar
- After adjust the position and frame, link the
dataSource
anddelegate
to the ViewController - Implement
FSCalendarDataSource
andFSCalendarDelegate
in ViewController.m
@property (weak , nonatomic) FSCalendar *calendar;
// In loadView or viewDidLoad
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, 320, 280)];
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: 280))
calendar.dataSource = self
calendar.delegate = self
view.addSubview(calendar)
self.calenar = calendar
- Paypal - f33chobits@gmail.com
@property (weak, nonatomic) IBOutlet id<FSCalendarDelegate> delegate;
A delegate object to handle user tap/scroll event, see FSCalendarDelegate
for details.
@property (weak, nonatomic) IBOutlet id<FSCalendarDataSource> dataSource;
A dataSource object to provide subtitle, event dot or other sources, see FSCalendarDataSource
for details.
@property (assign, nonatomic) FSCalendarFlow flow;
An enumeration value to determine the scroll direction of FSCalendar
, default value is FSCalendarFlowHorizontal
@property (assign, nonatomic) BOOL autoAdjustTitleSize;
The text size of FSCalendar
is automaticly calculated based on the frame by default. To turn it off, set this value to NO
.
@property (strong, nonatomic) NSDate *currentDate;
The current date of calendar, default is [NSDate date];
@property (strong, nonatomic) NSDate *selectedDate;
Get the selected date of FSCalendar
@property (strong, nonatomic) NSDate *currentMonth;
Get the current month of FSCalendar
.Extract it with NSDateComponents
, or currentMonth.fs_month
and currentMonth.fs_year
@property (assign, nonatomic) FSCalendarCellStyle cellStyle UI_APPEARANCE_SELECTOR;
The background style for today
and selected cell
, default is FSCalendarCellStyleCircle.
@property (strong, nonatomic) UIFont *titleFont UI_APPEARANCE_SELECTOR;
The font for day
text. To change the font size, set autoAdjustTitleSize
to NO
@property (strong, nonatomic) UIFont *subtitleFont UI_APPEARANCE_SELECTOR;
The font for subtitle
text. To change the font size, set autoAdjustTitleSize
to NO
@property (strong, nonatomic) UIFont *weekdayFont UI_APPEARANCE_SELECTOR;
The font for weekday
text. To change the font size, set autoAdjustTitleSize
to NO
@property (strong, nonatomic) UIFont *headerTitleFont UI_APPEARANCE_SELECTOR;
The font for scrolling header text. To change the font size, set autoAdjustTitleSize
to NO
@property (strong, nonatomic) UIColor *eventColor UI_APPEARANCE_SELECTOR;
The color for event dot.
@property (strong, nonatomic) UIColor *weekdayTextColor UI_APPEARANCE_SELECTOR;
The text color of weekday.
@property (strong, nonatomic) UIColor *titleDefaultColor UI_APPEARANCE_SELECTOR;
The day text color
for default state.
@property (strong, nonatomic) UIColor *titleSelectionColor UI_APPEARANCE_SELECTOR;
The day text color
for selection state.
@property (strong, nonatomic) UIColor *titleTodayColor UI_APPEARANCE_SELECTOR;
The day text color
where the date is equal to currentDate
.
@property (strong, nonatomic) UIColor *titlePlaceholderColor UI_APPEARANCE_SELECTOR;
The day text color
where the date is not
in currentMonth
.
@property (strong, nonatomic) UIColor *titleWeekendColor UI_APPEARANCE_SELECTOR;
The day text color
where the date is weekend.
@property (strong, nonatomic) UIColor *subtitleDefaultColor UI_APPEARANCE_SELECTOR;
The subtitle text color
for default state.
@property (strong, nonatomic) UIColor *subtitleSelectionColor UI_APPEARANCE_SELECTOR;
The subtitle text color
for selection state.
@property (strong, nonatomic) UIColor *subtitleTodayColor UI_APPEARANCE_SELECTOR;
The subtitle text color
where the date is equal to currentDate
.
@property (strong, nonatomic) UIColor *subtitlePlaceholderColor UI_APPEARANCE_SELECTOR;
The subtitle text color
where the date is not
in currentMonth
.
@property (strong, nonatomic) UIColor *subtitleWeekendColor UI_APPEARANCE_SELECTOR;
The subtitle text color
where the date is weekend.
@property (strong, nonatomic) UIColor *selectionColor UI_APPEARANCE_SELECTOR;
The cell background color
for selection state.
@property (strong, nonatomic) UIColor *todayColor UI_APPEARANCE_SELECTOR;
The cell background color
where the date is equal to currentDate
.
@property (strong, nonatomic) UIColor *headerTitleColor UI_APPEARANCE_SELECTOR;
The text color
for FSCalendarHeader
.
@property (strong, nonatomic) NSString *headerDateFormat UI_APPEARANCE_SELECTOR;
The date format
for FSCalendarHeader
.
- (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date;
To provide a subtitle right below the day
digit.
- (BOOL)calendar:(FSCalendar *)calendar hasEventForDate:(NSDate *)date;
To provide an event dot below the day cell.
- (BOOL)calendar:(FSCalendar *)calendar shouldSelectDate:(NSDate *)date;
To determine whether the day cell should be selected and show the selection layer.
- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date;
This method would execute after a cell is managed to be selected and show the selection layer.
- (void)calendarCurrentMonthDidChange:(FSCalendar *)calendar;
This method would execute when calendar month page is changed.
- (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar;
Provides a left boundary for calendar
- (NSDate *)maximumDateForCalendar:(FSCalendar *)calendar;
Provides a right boundary for calendar
ios 7.0
FSCalendar
is also tested on iPad device, see the demo for details.
- Smooth scrolling
- Add example of setup FSCalendar in
loadView
andviewDidLoad
- Simplier initialization: No more
FSCalendarHeader
, useheaderHeight
to control the size of header.
- Add minmumDate and maximumDate in FSCalendarDataSource
- Fix weekstarday issue
- Fix cell wrapping problem
- Fix problem while adding FSCalendar in viewDidLoad(cause by adjust scroll inset)
- Fix month-jumping problem on orientation changed #16
- Fix issue #20
- Fix lunar problem in demo project
- Fix issue #18
- Fix issue for different timeZone #14
- Fix date-calculation problem while changing
firstWeekday
- Fix problem about setting
flow
inviewDidLoad
#15
- Make
currentMonth
writable.FSCalendar
will showcurrentMonth
after it is set. - Add
firstWeekday
property. If you want the first day of week to be Monday, just set this property to2
, just likeNSCalendar
. - Add some performace improvements and code optimization.
- Make
selectedDate
writable.FSCalendar
will selectselectedDate
and show the corresponding month
- Improve scrolling performance
- Improve cell rendering performance
- The first release
- 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:
self.calendar.autoAdjustTitleSize = NO;
self.calendar.titleFont = otherTitleFont;
self.calendar.subtitleFont = otherSubtitleFont;
titleFont
and subtitleFont
is also available for UIAppearance
selector, but would not take any effect if autoAdjustTitleSize
value is YES
Wenchao Ding, f33chobits@gmail.com
FSCalendar is available under the MIT license. See the LICENSE file for more info.
- If FSCalendar cannot meet your requirment, welcome to submit issues or 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.