宽容他人,放过自己。

日历控件的使用

Posted on By anchoriteFili

相关链接


使用方法


1. 先将demo中图片拖出来添加
2. 将demo直接拉入到项目中。
3. 在使用日历文件中添加头文件 #import “CalendarView.h”
4. 在引用日历文件中添加相关代码
#import "CalendarViewController.h"
#import "MyCalendarItem.h"
#import "CalendarView.h"
@interface CalendarViewController ()<CalendarViewDelegate>

@property (nonatomic,retain) CalendarView *calenderView1;
@property (nonatomic,retain) UIButton *editButton; // 正在编辑的textField

@property (weak, nonatomic) IBOutlet UIButton *earlisetDateButton; // 最早的时间
@property (weak, nonatomic) IBOutlet UIButton *latestDateButton; // 最晚的时间



@end

@implementation CalendarViewController


- (void)viewDidLoad {
    
#pragma mark CalendarView部分

    [super viewDidLoad];
    self.calenderView1.delegate = self;
    

}

#pragma mark 时间按钮点击事件
- (IBAction)dateButtonClick:(UIButton *)sender {
    
    self.editButton = sender;
    self.calenderView1.frame = CGRectMake(0, 100, WIDTH, 335);
    self.calenderView1.hidden = NO;
    
    if (sender == self.earlisetDateButton) {
        
        [self.calenderView1 updateCalendarViewWithDateStyleEnum:EarlestDateStyleEnum];
        
        
    } else if (sender == self.latestDateButton) {
        
        [self.calenderView1 updateCalendarViewWithDateStyleEnum:LatestDateStyleEnum];
        
    }
}

- (void)selectEnsureDate:(NSString *)ensureDate {
    
    NSLog(@"ensureDate ====== %@",ensureDate);

    [self.editButton setTitle:ensureDate forState:UIControlStateNormal];

}

#pragma mark view懒加载
- (CalendarView *)calenderView1 {
    if (!_calenderView1) {
        _calenderView1 = [[CalendarView alloc] init];
        [self.view addSubview:self.calenderView1];
        self.calenderView1.hidden = YES;
        
    }
    return _calenderView1;
}

@end