/ Calendars

imitate Airbnb's calendar for iOS

imitate Airbnb's calendar for iOS

ZYCalendarView

Reference JTCalendar, imitate Airbnb's calendar

image

How to use

Download ZYCalendarView and try out the included you iPhone project or use CocoaPods.

Podfile

To integrate ZYCalendarView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
pod 'ZYCalendarView', '~> 0.0.2'
end

Then, run the following command:

$ pod install

Simple code

#import <ZYCalendarView.h>
    ZYCalendarView *view = [[ZYCalendarView alloc] initWithFrame:CGRectMake
                           (0, 64, self.view.frame.size.width, self.view.frame.size.height-64)];
    
    // 不可以点击已经过去的日期
    view.manager.canSelectPastDays = false;
    // 可以选择时间段
    view.manager.selectionType = ZYCalendarSelectionTypeRange;
    // 设置当前日期
    view.date = [NSDate date];
    
    view.dayViewBlock = ^(ZYCalendarManager *manager, NSDate *dayDate) {
        // NSLog(@"%@", dayDate);
        for (NSDate *date in manager.selectedDateArray) {
            NSLog(@"%@", [manager.dateFormatter stringFromDate:date]);
        }
        printf("\n");
    };

GitHub