[翻译] JTCalendar
JTCalendar
JTCalendar is a calendar control for iOS easily customizable.
JTCalendar 是一个很容易定制的日历的控件。



Usage
Basic usage - 基本使用方法
You have to create two views in your UIViewController.
你需要在你的UIViewController创建出两个view。
The first view is JTCalendarMenuView, it represents the months.
第一个view是JTCalendarMenuView,他代表着月份。
The second view is JTCalendarContentView, the calendar itself.
第二个view是JTCalendarContentView,这个是日历本身。
Your UIViewController must implement JTCalendarDataSource
你的UIViewController 必须实现JTCalendarDataSource代理。
#import <UIKit/UIKit.h> #import "JTCalendar.h" @interface ViewController : UIViewController<JTCalendarDataSource> @property (weak, nonatomic) IBOutlet JTCalendarMenuView *calendarMenuView;
@property (weak, nonatomic) IBOutlet JTCalendarContentView *calendarContentView; @property (strong, nonatomic) JTCalendar *calendar; @end
JTCalendar is used to coordinate calendarMenuView and calendarContentView.
JTCalendar 是用来定位calendarMenuView与 calendarContentView的。
@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
Switch to week view
切换到week
If you want see just one week at time you can switch when you want between the weekMode.
如果你只想看一周的时间,你可以切换到weekMode模式
self.calendar.calendarAppearance.isWeekMode = YES;
[self.calendar reloadAppearance];
WARNING
注意
When you change the mode, it doesn't change the height of calendarContentView, you have to do it yourself. See the project in example for more details.
当你切换样式时,他并没有改变calendarContentView的高度,你需要自己手动设置。你可以在项目中找到实现细节。
Customize the design
自定义设计
You have a lot of options available for personnalize the design. Check the JTCalendarAppearance.h file for see all options.
你有这很多很多的选项来定制设计。你可以再JTCalendarAppearance.h文件中找到这些配置选项。
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];
Recommendation
推荐用法
The call to reloadAppearance is expensive, reloadAppearance is call by setMenuMonthsView andsetContentView.
调用reloadAppearance 开销很大,setMenuMonthsView 与andsetContentView会调用reloadAppearance 方法
For better performance define the appearance just after instanciate JTCalendar.
BAD example:
self.calendar = [JTCalendar new]; [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]; // You have to call reloadAppearance
GOOD example:
self.calendar = [JTCalendar new]; 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]; // You don't have to call reloadAppearance
You may also want to open your calendar on a specific date, by defaut it's [NSDate date].
你也许想在打开日历的时候定位到指定的日期,默认值是[NSDate date]
[self.calendar setCurrentDate:myDate];
Requirements
- iOS 7 or higher
- Automatic Reference Counting (ARC)
[翻译] JTCalendar的更多相关文章
- 《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 ...
随机推荐
- LDA理解
LDA只是一个求解思路. 1.理解LDA首先要理解EM算法,EM不能叫做一个算法,只是一个思想:它要求解的其实是一个极大似然估计,就是我用已知量去求解导致这个已知量出现的最大概率,而在这里又恰恰有点偏 ...
- springboot-14-自定义properties文件值注入javaBean中
被这个问题困扰了好几天.... 在spring中, 从资源文件向bean中注入值非常简单, 只需要properties文件被spring加载, 然后在被spring管理的类写响应的属性, 然后 @Va ...
- java的if语句,少于一行可以省略大括号
我们认识的 if 语句,大概是这样的: if(条件){ 语句1; }else{ 语句2; } 如果要执行的语句少于1行,大括号是可以省略的 可以让程序更简洁和美观 if(条件){ 语句1; 语句2; ...
- Formtastic: Forms Made Crazy Easy for Rails Developers
Formtastic is a Rails plugin by Justin French that aims to take the headaches out of building forms ...
- MVC、MVCS、MVVM、MVP、VIPER等这么多架构模式哪一个好呢?
在项目开启阶段,其中一个很重要的环节就是选架构. 那么面对目前已知的这么多架构模式我们该怎么选择呢?这确实是个很让人头疼的问题! 下面我就在这里梳理一下目前常见的一些架构模式. 先逐个对它们的分析 ...
- [POI 2014]RAJ-Rally
Description 题库链接 给定一个 \(N\) 个点 \(M\) 条边的有向无环图,每条边长度都是 \(1\).请找到一个点,使得删掉这个点后剩余的图中的最长路径最短. \(1\leq N\l ...
- Firebird 获取用户表及字段
select rdb$relation_fields.rdb$relation_name table_name, rdb$relations.rdb$description table_des, rd ...
- [转]Configure Network Drive Visible for SQL Server During Backup and Restore Using SSMS
本文转自:https://mytechmantra.com/LearnSQLServer/Configure-Network-Drive-Visible-for-SQL-Server-During-B ...
- git分支branch合并到主分支master
如何使用git将分支branch合并到主干master上 对于一人独立使用git进行系统开发时,branch分支相当于版本(Version),如果每次都将新的分支branch提交到GitHub上,则会 ...
- Java多态-如何理解父类引用指向子类对象
java多态,如何理解父类引用指向子类对象 要理解多态性,首先要知道什么是“向上转型”. 我定义了一个子类Cat,它继承了Animal类,那么后者就是前者是父类.我可以通过 Cat c = new ...