[翻译] 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 ...
随机推荐
- 用css实现在横线中间插入文字
在一些登录或者注册界面中常常可看到,一个大框框上面的横线中有插入文字,大概示意图如下: 这种现象其实是相对位置作用的结果,可以通过相对定位,是某元素恰好出现在div的边框上. position: re ...
- 微信公众号H5支付
微信支付说明1.统一下单接口 统一支付接口: url: https://api.mch.weixin.qq.com/pay/unifiedorder 目的:通过此接口来创建预支付订单,获取订单支付需要 ...
- JavaScript文档对象模型
文档对象模型(Document Object Model, DOM)是W3C提出的用于访问和修改文档的接口. JavaScript设计的初衷是为Web提供交互功能,它通过DOM接口来访问和修改文档. ...
- Window环境配置Mongodb
Mongodb这几天也了解了一下,今天配置了下环境,从今天开始学下Mongodb数据库. 一.下载 在这个网址中选择要下载的开发环境https://www.mongodb.com/download-c ...
- oracle jdbc jar 的一些说明
Oracle Database 10g Release 2 JDBC Drivers You must accept the OTN Development and Distribution Lice ...
- webpack3+node+react+babel实现热加载(hmr)
前端工程化开发的一个重要标志就是热替换技术,它大大的提高开发效率,使我们专注于写代码,webpack3中的热替换相比较1更加简洁. 1. 先看效果 Demo地址 https://github.com/ ...
- tr循环,每行 2个数相加 求出和位第三个数赋值 (http://jsfiddle.net/hgeL44rz/113/)
<table id="tb"> <tr> <th>单价</th> <th>数量</th> <th> ...
- centos7下更新firefox
下载最新版firefox 1.点击三条线-问号-firefox帮助-安装和更新-linux安装-系统和语言下载 保存到指定目录,比如home下 2.解压 tar xjf firefox-*.tar.b ...
- mysql 删除某一个数据库下面的所有表,但不删除数据库
删除某一个数据库下面的所有表,但不删除数据库.该语句经过从concat拼接,最后查询出来的是删除表的语句,然后执行那些查询出来的语句就ok了select concat(‘drop table ‘,ta ...
- Laravel 支付宝支付异步通知
支付宝支付通知有前端通知(GET)和服务器异步通知(POST) 在配置支付宝支付时,需要注意的问题就是支付宝的回调操作: 1.在laravel中应该将支付宝通知路径组织csrf验证,否则会导致419错 ...