《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRCalendarView.m 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // DRCalendarView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/8/3.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRCalendarView.h"
  9. #import "LXCalender.h"
  10. @interface DRCalendarView(){
  11. __block NSString *_dateStr;
  12. }
  13. @property(nonatomic,strong) LXCalendarView *calenderView;
  14. @end
  15. @implementation DRCalendarView
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. self.layer.cornerRadius = Fitsize(6);
  20. self.layer.masksToBounds = YES;
  21. [self initSubViews];
  22. }
  23. return self;
  24. }
  25. - (void)initSubViews {
  26. self.calenderView =[[LXCalendarView alloc]initWithFrame:CGRectMake(0, 0, self.width, 0)];
  27. self.calenderView.layer.masksToBounds = YES;
  28. self.calenderView.currentMonthTitleColor =[UIColor YHColorWithHex:0x2c2c2c];
  29. self.calenderView.lastMonthTitleColor =[UIColor YHColorWithHex:0x8a8a8a];
  30. self.calenderView.nextMonthTitleColor =[UIColor YHColorWithHex:0x8a8a8a];
  31. self.calenderView.isHaveAnimation = YES;
  32. self.calenderView.isCanScroll = YES;
  33. self.calenderView.isShowLastAndNextBtn = YES;
  34. self.calenderView.todayTitleColor =[UIColor homeRedColor];
  35. self.calenderView.selectBackColor =[UIColor homeRedColor];
  36. self.calenderView.isShowLastAndNextDate = NO;
  37. [self.calenderView dealData];
  38. self.calenderView.backgroundColor =[UIColor whiteColor];
  39. self.calenderView.selectBlock = ^(NSInteger year, NSInteger month, NSInteger day) {
  40. NSLog(@"%ld年 - %ld月 - %ld日",year,month,day);
  41. _dateStr = [NSString stringWithFormat:@"%ld-%ld-%ld",year,month,day];
  42. };
  43. [self addSubview:self.calenderView];
  44. UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.calenderView.bottom, self.width, Fitsize(60))];
  45. bottomView.backgroundColor = [UIColor whiteColor];
  46. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(15, 0, Fitsize(60), bottomView.height)];
  47. [leftBtn setTitle:@"取消" forState:UIControlStateNormal];
  48. [leftBtn setImage:[UIImage imageNamed:@"cancel_c"] forState:UIControlStateNormal];
  49. [leftBtn setTitleColor:[UIColor YHColorWithHex:0x2C3135] forState:UIControlStateNormal];
  50. leftBtn.titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
  51. [leftBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
  52. [leftBtn setButtonImageTitleStyle:ButtonImageTitleStyleLeft padding:5];
  53. [bottomView addSubview:leftBtn];
  54. UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(bottomView.width-15-Fitsize(60), 0, Fitsize(60), bottomView.height)];
  55. [rightButton setTitleColor:[UIColor YHColorWithHex:0x2C3135] forState:UIControlStateNormal];
  56. rightButton.titleLabel.font = [UIFont systemFontOfSize:Fitsize(12)];
  57. [rightButton setTitle:@"确定" forState:UIControlStateNormal];
  58. [rightButton setImage:[UIImage imageNamed:@"save_c"] forState:UIControlStateNormal];
  59. [rightButton setButtonImageTitleStyle:ButtonImageTitleStyleLeft padding:5];
  60. [rightButton addTarget:self action:@selector(makeSureAction) forControlEvents:UIControlEventTouchUpInside];
  61. [bottomView addSubview:rightButton];
  62. [self addSubview:bottomView];
  63. self.height = self.calenderView.height+bottomView.height;
  64. }
  65. - (void)cancelAction {
  66. if (self.cancelBlock) {
  67. self.cancelBlock();
  68. }
  69. }
  70. - (void)makeSureAction {
  71. if (self.makeSureBlock) {
  72. if (!_dateStr) {
  73. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  74. [formatter setDateFormat:@"yyyy-MM-dd"];
  75. NSDate *datenow = [NSDate date];
  76. _dateStr = [formatter stringFromDate:datenow];
  77. }
  78. self.makeSureBlock(_dateStr);
  79. }
  80. }
  81. @end