【代码笔记】日历

一, 效果图。

【代码笔记】日历_第1张图片

二,工程图。

【代码笔记】日历_第2张图片

三,代码。

RootViewController.h

复制代码
#import <UIKit/UIKit.h>

#import "CalendarView.h"
#import "CalendarUtils.h"
#import "CalendarStyle.h"

@interface RootViewController : UIViewController <CalendarViewDelegate> { CalendarView *calendarView; } @end
复制代码

 

RootViewController.m

复制代码
#import "RootViewController.h"

@interface RootViewController () @end

@implementation RootViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization
 } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view.
 self.title=@"Calendar"; [self initWithCalendarView]; } -(void)initWithCalendarView { if(calendarView) [calendarView removeFromSuperview]; calendarView = [[CalendarView alloc]initWithFrame:CGRectMake(10, self.view.bounds.size.height - 200 - 320 + 20, 300, 300)]; [calendarView refleshriCheng:^(NSDate *date,NSString *str) { if([str isEqualToString:@"left"]){ UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"点击了左侧按钮" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; [alert show]; } else if([str isEqualToString:@"right"]){ UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"点击了右侧按钮" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; [alert show]; } }]; calendarView.delegate=self; [self.view addSubview:calendarView]; } #pragma -mark -CalendarViewDelegate
- (void) calendarViewDidSelectDate:(NSDate *)date todayDate:(NSDate *)todayDate { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"点击了日期" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; [alert show]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.
}
复制代码

 


你可能感兴趣的:(【代码笔记】日历)