[翻译] SACalendar
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)
Installation
Add the SACalendar folder into your project. Make sure the "copy items into destination group's folder" box is checked 将SACalendar添加到你的项目当中,记得勾选“folder”
Done 完啦
Basic Usage
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];
}
Delegate (optional)
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);
}
Customize
- To customize the view properties such as cell size, font, colors, please see the class 为了定制view的属性,例如cell的size,font,colors,你可以到cell中去看看
SACalendarConstants.h
All ratio and UI constants are defined in this class. Change them to support your need.
所有的参数与样式都是在这个类中被定义了。你可以随意修改来达到你的需求。
- To customize the logic behind what's being displayed in the cells (i.e. red circle at selected date), see this function in SACalendar.m 你可以查看SACalendar.m文件来自定义cell背后的逻辑
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- To customize the components (subviews) of the cell or to add some views to the cell, please see this function in SACalendarCell.m 你可以查看SACalendarCell.m文件来自定义cell的显示样式
- (id)initWithFrame:(CGRect)frame
[翻译] SACalendar的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- 修改MVC默认的pageBaseType以添加功能
试想下在MVC的前端页面JS或者html中需要使用多语言,而后端的多语言是维护在资源文件中的,前端如果使用的话需要使用AJAX频繁的获取,一个页面中可能会存在大量的需要语言转换的地方,频繁使用AJAX ...
- Java生成指定范围内的工具类
/** * 生成[min, max]之间的随机整数 * * @param min 最小整数 * @param max 最大整数 * @return * @author jqlin */ private ...
- Message小结(一)
一.消息版本 为了区别消息的结构和寻址机制,W3C定制了SOAP1.1和SOAP1.2定义消息的结构,WS-Addressing 2004和WS-Addressing 1.0定义消息的寻址机制. ...
- Angular待办事项应用2
todo组件 接上一篇,在根目录创建todo组件 命令行输入:ng g c todo 得到 文件结构 修改默认路由为todo: 然后打开浏览器:http://localhost:4200/ ,查看,t ...
- struts2入门实例
引言: 接触.net有3.4年的时间了,一直想学习java,中间因为种种原因耽搁下来.本人学习java的目的,一是多条出路,二是和.net平台互相印证,毕竟只用一门语言,无论是在框架还是在眼界方面都会 ...
- 我在项目中运用 IOC(依赖注入)--实战篇
上一篇<我在项目中运用 IOC(依赖注入)--入门篇>只是简单的使用 IOC.实际项目使用 IOC 的情景复杂多了,比如说,构造函数有多个参数,有多个类继承同一个接口... Unity都有 ...
- Java基础教程(14)--嵌套类
Java允许在一个类中定义另外一个类,这样的类被称为嵌套类,就像下面这样: class OuterClass { ... class NestedClass { ... } } 嵌套类分为两种 ...
- @Value失效的问题
@Value 会在@Controller中失效,失效原因涉及源码问题就不一一叙述了,一般加上@Service,@Component就能解决.如果是在Controller中使用建议新建一个配置类,然后在 ...
- MySQL千万级大表优化解决方案
MySQL千万级大表优化解决方案 非原创,纯属记录一下. 背景 无意间看到了这篇文章,作者写的很棒,于是乎,本人自私一把,把干货保存下来.:-) 问题概述 使用阿里云rds for MySQL数据库( ...
- R语言与.net 集成开发入门
首先:R语言的基本教程: https://www.yiibai.com/r/r_environment_setup.html 下载R语言的安装包:https://cran.r-project.org/ ...