123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- //
- // DRCalendarView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/8/3.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRCalendarView.h"
- #import "LXCalender.h"
- @interface DRCalendarView(){
- __block NSString *_dateStr;
- }
- @property(nonatomic,strong) LXCalendarView *calenderView;
- @end
- @implementation DRCalendarView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.layer.cornerRadius = Fitsize(6);
- self.layer.masksToBounds = YES;
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- self.calenderView =[[LXCalendarView alloc]initWithFrame:CGRectMake(0, 0, self.width, 0)];
- self.calenderView.layer.masksToBounds = YES;
- self.calenderView.currentMonthTitleColor =[UIColor YHColorWithHex:0x2c2c2c];
- self.calenderView.lastMonthTitleColor =[UIColor YHColorWithHex:0x8a8a8a];
- self.calenderView.nextMonthTitleColor =[UIColor YHColorWithHex:0x8a8a8a];
-
- self.calenderView.isHaveAnimation = YES;
-
- self.calenderView.isCanScroll = YES;
- self.calenderView.isShowLastAndNextBtn = YES;
-
- self.calenderView.todayTitleColor =[UIColor homeRedColor];
-
- self.calenderView.selectBackColor =[UIColor homeRedColor];
-
- self.calenderView.isShowLastAndNextDate = NO;
-
- [self.calenderView dealData];
-
- self.calenderView.backgroundColor =[UIColor whiteColor];
-
- self.calenderView.selectBlock = ^(NSInteger year, NSInteger month, NSInteger day) {
- NSLog(@"%ld年 - %ld月 - %ld日",year,month,day);
- _dateStr = [NSString stringWithFormat:@"%ld-%ld-%ld",year,month,day];
- };
-
- [self addSubview:self.calenderView];
-
- UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.calenderView.bottom, self.width, Fitsize(60))];
- bottomView.backgroundColor = [UIColor whiteColor];
- UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(15, 0, Fitsize(60), bottomView.height)];
- [leftBtn setTitle:@"取消" forState:UIControlStateNormal];
- [leftBtn setImage:[UIImage imageNamed:@"cancel_c"] forState:UIControlStateNormal];
- [leftBtn setTitleColor:[UIColor YHColorWithHex:0x2C3135] forState:UIControlStateNormal];
- leftBtn.titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
- [leftBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
- [leftBtn setButtonImageTitleStyle:ButtonImageTitleStyleLeft padding:5];
- [bottomView addSubview:leftBtn];
-
- UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(bottomView.width-15-Fitsize(60), 0, Fitsize(60), bottomView.height)];
- [rightButton setTitleColor:[UIColor YHColorWithHex:0x2C3135] forState:UIControlStateNormal];
- rightButton.titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
- [rightButton setTitle:@"确定" forState:UIControlStateNormal];
- [rightButton setImage:[UIImage imageNamed:@"save_c"] forState:UIControlStateNormal];
- [rightButton setButtonImageTitleStyle:ButtonImageTitleStyleLeft padding:5];
- [rightButton addTarget:self action:@selector(makeSureAction) forControlEvents:UIControlEventTouchUpInside];
- [bottomView addSubview:rightButton];
- [self addSubview:bottomView];
- self.height = self.calenderView.height+bottomView.height;
-
- }
- - (void)cancelAction {
- if (self.cancelBlock) {
- self.cancelBlock();
- }
- }
- - (void)makeSureAction {
- if (self.makeSureBlock) {
- if (!_dateStr) {
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSDate *datenow = [NSDate date];
- _dateStr = [formatter stringFromDate:datenow];
- }
- self.makeSureBlock(_dateStr);
- }
- }
- @end
|