Use your own calendar with a quick project

I need to implement my own custom calendar, but I'm new to ios and don't know how to do it! I read different articles, but realized that I do not do this myself! maybe there is some library to do eto.Spasibo for any help!

+3


source to share


1 answer


Use this cocoa pods, it is very convenient and easy to use JTCalendar

Primary use

You need to create two views in your UIViewController.

The first view is JTCalendarMenuView and it represents months.

The second view is the JTCalendarContentView, the calendar itself.



Your UIViewController must implement JTCalendarDataSource

#import <UIKit/UIKit.h>

#import "JTCalendar.h"

@interface ViewController : UIViewController<JTCalendarDataSource>

@property (weak, nonatomic) IBOutlet JTCalendarMenuView *calendarMenuView;
@property (weak, nonatomic) IBOutlet JTCalendarContentView *calendarContentView;

@property (strong, nonatomic) JTCalendar *calendar;

@end
JTCalendar is used to coordinate calendarMenuView and calendarContentView.

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.calendar = [JTCalendar new];

    [self.calendar setMenuMonthsView:self.calendarMenuView];
    [self.calendar setContentView:self.calendarContentView];
    [self.calendar setDataSource:self];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [self.calendar reloadData]; // Must be call in viewDidAppear
}

- (BOOL)calendarHaveEvent:(JTCalendar *)calendar date:(NSDate *)date
{
    return NO;
}

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

@end

      

For details on how to organize events by date, see the sample project.

https://github.com/jonathantribouharet/JTCalendar

+4


source







All Articles