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. Jquery的toggle()方法

    toggle()并不是仅仅能 显示/隐藏而已 它的格式如下 toggle(fn1,fn2,fn3.....) 也就是说,它的参数可以说不定数目的 若干个方法,然后每个方法按顺序轮番调用 $(docum ...

  2. Linux下安装了Xampp,但命令行使用不了MySQL

    引用:http://www.2cto.com/database/201406/309521.html   刚安装好Xampp,使用localhost也能正常运行, phpMyAdimin也能正常登录 ...

  3. Linux用户信息查询

    1 查询目前已登录的用户信息w 或者 who [@bjzw_11_210 ~]# w :: up days, :, users, load average: 0.03, 0.04, 0.00 USER ...

  4. Object类上的方法

    1.getClass: public final native Class<?> getClass(); 返回当前对象运行时的类的对象. 2.hashCode: public native ...

  5. input 控件监听回车确认按钮。

    前端开发的同学捕捉回车按键经常会用到 if(event.keyCode == 13){ console.log("点击了回车按键");} 但是在微信上面,我们一般会用到指令 bin ...

  6. python学习之老男孩python全栈第九期_day016作业

    1. 请利用filter()过滤出1~100中平方根是整数的数,即结果应该是: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] import math def func( ...

  7. 基于AlipayJSBridge封装的H5网页支付宝打赏、网站打赏、个人免签支付,支付宝转账打赏支付组件

    之前公司要做个打赏用户的功能,网站查询一些资料之后把一些api封装之后提供了一个demo组件供大家下载:扫描下图二维码 功能: 支付宝H5 Js方案,调起应用内页面,自动设定转账金额和收款理由,用户付 ...

  8. window平台安装node.js绿色版

    1. 下载Windows Binary版本的node.js文件 2. 把下载的ZIP压缩包解压到某个目录下(例如:D:\nodejs) 3. 此时的node.js只在刚刚解压的目录才起作用,需要配置环 ...

  9. 正能量:You Are the Best

    Success comes from knowing that you did your best to become the best that you are capable of becomin ...

  10. ul制作导航菜单

    首先上图,最终效果: HTML代码: <!DOCTYPE html><html> <head> <meta charset="utf-8" ...