mohsinalimat / ios_calendar

iOS calendar component

Home Page:http://www.maximbilan.com.ua/ios-7-calendar-component/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iOS Calendar

It's lightweight and simple control. There're samples for iphone and ipad, and also with using popover.
alt tag
Using popover:

alt tag

How to use:
Add to your project source files:

CalendarView.h
CalendarView.m
NSDate+CalendarView.h
NSDate+CalendarView.m

You can add view in the Interface builder and set class to CalendarView or create in the code:

CalendarView *cv = [[CalendarView alloc] initWithPosition:10.0 y:10.0];
[self.view addSubview:cv];

So, it's all, you should see the calendar view.
This component was created for iphone/ipod resolution, for ipad it's works, but it looks really small, if it's necessary, you can playing with static constants in the CalendarView.m, and maybe in future, will be done the scaling.
This calendar has some modes:

typedef NS_ENUM(NSInteger, CalendarMode)
{
    CM_Default,
    CM_MonthsAndYears,
    CM_Years
};

Default - there're days, months and years, the user can change monthes with help swipe gesture or pinch gesture for transitions in the calendar
MonthsAndYears - available months and years
Years - only years

How to handle changing date event:
For this you should use CalendarViewDelegate protocol:

@interface ViewController : UIViewController <CalendarViewDelegate>

@end

And setup delegate:

self.calendarView.calendarDelegate = self;

After that you should implement required method didChangeCalendarDate:

- (void)didChangeCalendarDate:(NSDate *)date
{
    NSLog(@"didChangeCalendarDate:%@", date);
}

For more details there're optional methods for other things:

@optional
- (void)didChangeCalendarDate:(NSDate *)date withType:(NSInteger)type withEvent:(NSInteger)event;
- (void)didDoubleTapCalendar:(NSDate *)date withType:(NSInteger)type;

How to customize colors:
For customization of colors you can use the following properties:
// Main color of numbers
@property (nonatomic, strong) UIColor *fontColor;
// Color of the headers (Year and month)
@property (nonatomic, strong) UIColor *fontHeaderColor;
// Color of selected numbers
@property (nonatomic, strong) UIColor *fontSelectedColor;
// Color of selection
@property (nonatomic, strong) UIColor *selectionColor;
For example:
self.calendarView.selectionColor = [UIColor colorWithRed:0.203 green:0.666 blue:0.862 alpha:1.000];
self.calendarView.fontHeaderColor = [UIColor colorWithRed:0.203 green:0.666 blue:0.862 alpha:1.000];
And you can see the result:
![alt tag](https://raw.github.com/maximbilan/ios_calendar/master/img/img6.png)
It's free for using, feel free. And I hope it will be helpful.
More information about this you can found here.

About

iOS calendar component

http://www.maximbilan.com.ua/ios-7-calendar-component/

License:MIT License


Languages

Language:Objective-C 100.0%