JTCalendar是一款简易使用而且能够自己定义事件的日历。包含圈点标识的颜色等都能够自己定义。demo中还提供了转换日历模式的样例。
效果图:
用法:
JTCalendar支持CocoaPod. 导入头文件#import "JTCalendar.h"后,你须要创建两个View来放入月份和日历: @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet JTCalendarMenuView *calendarMenuView; @property (weak, nonatomic) IBOutlet JTCalendarContentView *calendarContentView; @property (strong, nonatomic) JTCalendar *calendar; @end 然后就能够在VC中实现了: @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.calendar = [JTCalendar new]; [self.calendar setMenuMonthsView:self.calendarMenuView]; [self.calendar setContentView:self.calendarContentView]; [self.calendar setDataSource:self]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self.calendar reloadData]; // (必需要在这里调用)Must be call in viewDidAppear } - (BOOL)calendarHaveEvent:(JTCalendar *)calendar date:(NSDate *)date { return NO; } - (void)calendarDidDateSelected:(JTCalendar *)calendar date:(NSDate *)date { NSLog(@"%@", date); } @end 另外假设须要改变设置一些參数的话,请在设置日历前设定: self.calendar.calendarAppearance.calendar.firstWeekday = 2; // Monday self.calendar.calendarAppearance.ratioContentMenu = 1.; self.calendar.calendarAppearance.menuMonthTextColor = [UIColor whiteColor]; self.calendar.calendarAppearance.dayCircleColorSelected = [UIColor blueColor]; self.calendar.calendarAppearance.dayTextColorSelected = [UIColor whiteColor]; [self.calendar setMenuMonthsView:self.calendarMenuView]; [self.calendar setContentView:self.calendarContentView]; [self.calendar setDataSource:self]; 假设这样写的话,就须要reloadAppearance一下: [self.calendar setMenuMonthsView:self.calendarMenuView]; [self.calendar setContentView:self.calendarContentView]; [self.calendar setDataSource:self]; self.calendar.calendarAppearance.calendar.firstWeekday = 2; // Monday self.calendar.calendarAppearance.ratioContentMenu = 1.; self.calendar.calendarAppearance.menuMonthTextColor = [UIColor whiteColor]; self.calendar.calendarAppearance.dayCircleColorSelected = [UIColor blueColor]; self.calendar.calendarAppearance.dayTextColorSelected = [UIColor whiteColor]; [self.calendar reloadAppearance]; 所以注意好顺序。 最后日历也提供方法设置日趋: [self.calendar setCurrentDate:myDate]; 下载地址
http://code4app.com/ios/JTCalendar/546184d1933bf0a8518b48c8