• [翻译] 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
  • 相关阅读:
    4.qml-ECMAScript(Array对象、Math对象)
    3.qml-ECMAScript_03(Object基类对象、String对象)
    2.qml-ECMAScript_02(原始值类型、通用转换方法)
    ORA-00001: 违反唯一约束条件(SOLEX.SYS_C0012537) --解决方法
    macOS 系统打开和退出文件夹(cd命令)
    macOS 系统下node安装和环境配置(通过node官网)
    macOS 系统报错:zsh:command not found :npm
    macOS 系统更新node老是不成功
    macOS 系统上升级 Python
    maxOS 系统更新node版本
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4436000.html
Copyright © 2020-2023  润新知