• [翻译] 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
  • 相关阅读:
    POJ 2112 Optimal Milking (Floyd+二分+最大流)
    hdu5444 Elven Postman
    hdu5442 Favorite Donut
    hdu5437 Alisha’s Party
    hdu5433 Xiao Ming climbing
    hdu5432 Pyramid Split
    Codeforces Round #316 (Div. 2) C. Replacement
    hdu5396 Expression
    hdu3506 Monkey Party
    hdu3516 Tree Construction
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4436000.html
Copyright © 2020-2023  润新知