iOS日历视图:GLCalendarView
jopen
9年前
GLCalendarView 是一款完全自定义的日历视图,可以作为日期范围选择器。
用法
- Init the view by placing it in the storyboard or programmatically init it and add it to your view controller.
- InviewDidLoad, set thefirstDateandlastDateof the calendarView.
- InviewWillAppear, set up the model data and call[self.calendarView reload];to refresh the calendarView.
To display some ranges in the calendar view, construct someGLCalendarDateRangeobjects, set them as the model of the calendar view
NSDate *today = [NSDate date]; NSDate *beginDate = [GLDateUtils dateByAddingDays:-23 toDate:today]; NSDate *endDate = [GLDateUtils dateByAddingDays:-18 toDate:today]; GLCalendarDateRange *range = [GLCalendarDateRange rangeWithBeginDate:beginDate endDate:endDate]; range.backgroundColor = COLOR_BLUE; range.editable = YES; range.binding = yourModelObject // you can bind your model to the range self.calendarView.ranges = [@[range1] mutableCopy]; [self.calendarView reload];