FSCalendar/Example/LoadViewExampleViewControll...

81 lines
2.0 KiB
Objective-C

//
// LoadViewExampleViewController.m
// FSCalendar
//
// Created by DingWenchao on 6/25/15.
// Copyright (c) 2015 =. All rights reserved.
//
#import "LoadViewExampleViewController.h"
#import "NSDate+FSExtension.h"
@implementation LoadViewExampleViewController
- (void)dealloc
{
NSLog(@"%@:%s", self.class.description, __FUNCTION__);
}
- (instancetype)init
{
self = [super init];
if (self) {
self.title = @"FSCalendar";
}
return self;
}
- (void)loadView
{
UIView *view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
view.backgroundColor = [UIColor whiteColor];
self.view = view;
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 64, view.frame.size.width, 300)];
calendar.dataSource = self;
calendar.delegate = self;
calendar.scrollDirection = FSCalendarScrollDirectionVertical;
[calendar selectDate:[NSDate fs_dateWithYear:2015 month:2 day:1]];
[view addSubview:calendar];
self.calendar = calendar;
}
- (BOOL)calendar:(FSCalendar *)calendar shouldSelectDate:(NSDate *)date
{
NSLog(@"should select date %@",[date fs_stringWithFormat:@"yyyy/MM/dd"]);
return YES;
}
- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date
{
NSLog(@"did select date %@",[date fs_stringWithFormat:@"yyyy/MM/dd"]);
}
- (void)calendarCurrentMonthDidChange:(FSCalendar *)calendar
{
NSLog(@"did change to month %@",[calendar.currentMonth fs_stringWithFormat:@"MMMM yyyy"]);
}
//- (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];
//}
- (UIImage *)calendar:(FSCalendar *)calendar imageForDate:(NSDate *)date
{
if (date.fs_day == 5) {
return [UIImage imageNamed:@"icon_footprint"];
}
if (date.fs_day == 10 || date.fs_day == 15) {
return [UIImage imageNamed:@"icon_cat"];
}
return nil;
}
@end