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的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. .bat学习-基础语法(常用)

    一般来说,脚本或者语言都有相同地方 定义变量,输入,输出,判断条件等等.知道的相同之处,我们就可以借助强大的搜索引擎进行查找我们想要知道的东西. bat为批处理脚本BATCH.现在只知道是使用于win ...

  2. Android JNI初体验

    欢迎转载,转载请注明出处:http://www.cnblogs.com/lanrenxinxin/p/4696991.html 开始接触Android JNI层面的内容,推荐一本不错的入门级的书< ...

  3. 169.254地址无网关信息 ----- 解决方案 启动DHCP服务

    169.254.X.X是Windows操作系统在DHCP信息租用失败时自动给客户机分配的IP地址,.看到地址的时候没有网关. 解决方案   启动DHCP服务 1. 首先确认 路由器  DHCP 服务已 ...

  4. Golang cron 定时任务使用

    1.cron 表达式的基本格式 用过 linux 的应该对 cron 有所了解.linux 中可以通过 crontab -e 来配置定时任务.不过,linux 中的 cron 只能精确到分钟.而我们这 ...

  5. [转]wx.getUserInfo(OBJECT) 微信小程序 获取用户信息

    本文转自:http://mp.weixin.qq.com/debug/wxadoc/dev/api/open.html wx.getUserInfo(OBJECT) 获取用户信息,withCreden ...

  6. asp后台读id设置样式

    加runat=“server”

  7. 线程8--GCD常见用法

    1.延迟执行 /***********************延迟第一种方法**************************/ /* 第一种方法, 调用NSObject的方法 [self perf ...

  8. 二:Servlet

    一:servlet开端 1.servlet是什么? a.就是一个java类 b.服务器端的小程序 c.处理用户请求 2.servlet的实现: a.实现Servlet接口 b.继承GenericSer ...

  9. MySQL 中文未正常显示

    关于MySQL中文乱码问题 最近发现,在MySQL的dos客户端输出窗口中查询表中的数据时,表中的中文数据都显示成乱码: 之所以会显示乱码,就是因为MySQL客户端输出窗口显示中文时使用的字符编码不对 ...

  10. Git 学习之Git 基础(二)

    Git 基础 读完本章你就能上手使用 Git 了.本章将介绍几个最基本的,也是最常用的 Git 命令,以后绝大多数时间里用到的也就是这几个命令.读完本章,你就能初始化一个新的代码仓库,做一些适当配置: ...