[翻译] 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
目录
相关文章
|
11月前
|
存储 SQL 分布式计算
大数据学习
【10月更文挑战第15天】
293 1
|
10月前
|
开发工具 git 开发者
|
机器学习/深度学习 人工智能 数据库
飞天技术观|大模型时代,从软件工程到打通行业智能的“最后一公里”
与以往基于白盒化的软件工程范式相比,大模型能够成为新范式,提供真正的智能化引擎,从而使业务应用更高效和智能性。在这种模式下,阿里云将自身定位成大模型时代的算力服务提供者,希望能够为千行百业打通业务智能化的“最后一公里”。
972 2
|
Dart 开发者 UED
flutter 非常用组件整理 第三篇
本文是非常用组件的第三讲,介绍了一些不为人知但却能大幅提升Flutter应用UI效果和功能的高级组件,包括FadeInImage、GridPaper、Hero等,为开发者带来更丰富的UI设计可能。
228 3
flutter 非常用组件整理 第三篇
|
Web App开发 监控 网络协议
在Linux中,当用户反馈网站访问慢,如何处理?
在Linux中,当用户反馈网站访问慢,如何处理?
|
消息中间件 设计模式 监控
中间件事件总线(Event Bus)
【6月更文挑战第19天】
355 8
|
Web App开发 前端开发 JavaScript
探索 V8 引擎的内部:深入理解 JavaScript 执行的本质
探索 V8 引擎的内部:深入理解 JavaScript 执行的本质
探索 V8 引擎的内部:深入理解 JavaScript 执行的本质
|
存储 编解码 算法
使用Python和OpenCV构建具有人体检测功能的摄像头录制器
使用Python和OpenCV构建具有人体检测功能的摄像头录制器
|
数据安全/隐私保护
阿里云域名购买至备案流程
阿里云域名购买至备案流程