Skip to content

Latest commit

 

History

History
70 lines (49 loc) · 2.18 KB

README.md

File metadata and controls

70 lines (49 loc) · 2.18 KB

objc-CGCalendarView

A Lightweight Horizontal Calendar/Date Picker inspired by Square's TimesSquare https://github.com/square/objc-TimesSquare

Created for CapitalGene iOS App

Screenshot

Usage

Screenshot

import CGCalendarView.h and CGCalendarCell.h

```objective-c

- (void)setupCalendarView
{
    // initalize calendarView with frame
    self.calendarView = [[CGCalendarView alloc] initWithFrame:CGRectMake(0, 20, 320, CG_CALENDAR_VIEW_HEIGHT)];
    // use a global NSCalendar
    self.calendarView.calendar = calendar;

    // Set the background color
    self.calendarView.backgroundColor = [UIColor lightGrayColor];

    // Set the RowCellClass
    self.calendarView.rowCellClass = [CGCalendarCell class];

    // The beginning date
    self.calendarView.firstDate = [NSDate dateWithTimeIntervalSinceNow: -60 * 60 * 24 * 30];

    // The end date
    self.calendarView.lastDate = [NSDate dateWithTimeIntervalSinceNow:60 * 60 * 24 * 180];

    // didSelectDate delegate
    self.calendarView.delegate = self;

    // Add the calendarView as a subview
    [self.view addSubview:self.calendarView];

    // Select Today
    self.calendarView.selectedDate = [NSDate date];

    // Prepare a dateformatter for displaying the selected
    // date
    self.DF = [[NSDateFormatter alloc] init];
    [self.DF setDateFormat:@"yyyy-MM-dd"];
}
```

Authors

Chen Liang

Credits

License:

Licensed under the MIT license