标签:
SACalendar
效果图:
Introducing SACalendar - Easy to use and customizable iOS 7 Calendar
SACalendar - 使用非常傻瓜,非常便于定制
Only need 3 lines of code to set up. Every view customizable to fit your need.
只需要3行代码,所有的事情就做好了
This project uses the customized version of DMLazyScrollView (https://github.com/malcommac/DMLazyScrollView)
这个源码中部分使用到了DMLazyScrollView (https://github.com/malcommac/DMLazyScrollView)
Add the SACalendar folder into your project. Make sure the "copy items into destination group‘s folder" box is checked 将SACalendar添加到你的项目当中,记得勾选“folder”
Done 完啦
Import the class header
引入头文件
#import "SACalendar.h"
Initialize your calendar with the appropriate frame. The calendar will scale to fit your frame automatically.
初始化你的日历的frame值,这个日历会自动适配你的frame值的,这点放心
- (void)viewDidLoad
{
[super viewDidLoad];
SACalendar *calendar = [[SACalendar alloc]initWithFrame:CGRectMake(0, 20, 320, 400)];
calendar.delegate = self;
[self.view addSubview:calendar];
}
SACalendar provides two delegate methods. didSelectDate gets called when a user click on a specific date. didDisplayCalendarForMonth gets called when the user swipe the calendar to a different month. To use it, implement the delegate in your view controller.
SACalendar提供两个代理方法。当一个日期被点击时didSelectDate会被调用。用户滑动切换月份时,didDisplayCalendarForMonth会被调用。将代理引入到你的控制器中即可使用。
@interface ViewController () <SACalendarDelegate>
Then implement the optional delegate functions
以下是两个可选的代理方法
// Prints out the selected date
-(void) SACalendar:(SACalendar*)calendar didSelectDate:(int)day month:(int)month year:(int)year
{
NSLog(@"%02i/%02/%i",month,year);
}
// Prints out the month and year displaying on the calendar
-(void) SACalendar:(SACalendar *)calendar didDisplayCalendarForMonth:(int)month year:(int)year{
NSLog(@"%02/%i",month,year);
}
SACalendarConstants.h
All ratio and UI constants are defined in this class. Change them to support your need.
所有的参数与样式都是在这个类中被定义了。你可以随意修改来达到你的需求。
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- (id)initWithFrame:(CGRect)frame
标签:
原文地址:http://www.cnblogs.com/YouXianMing/p/4436000.html