猎豆优选

LXCalenderCell.m 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // LXCalenderCell.m
  3. // LXCalendar
  4. //
  5. // Created by chenergou on 2017/11/2.
  6. // Copyright © 2017年 漫漫. All rights reserved.
  7. //
  8. #import "LXCalenderCell.h"
  9. #import "LxButton.h"
  10. #import "UIColor+Expanded.h"
  11. #import "UILabel+LXLabel.h"
  12. #import "UIView+LX_Frame.h"
  13. #import "UIView+FTCornerdious.h"
  14. #import "NSString+NCDate.h"
  15. @interface LXCalenderCell()
  16. @property (weak, nonatomic) IBOutlet UILabel *label;
  17. @end
  18. @implementation LXCalenderCell
  19. - (void)awakeFromNib {
  20. [super awakeFromNib];
  21. // Initialization code
  22. self.label.textColor = [UIColor YHColorWithHex:0x2C3135];
  23. self.label.font = [UIFont systemFontOfSize:Fitsize(12)];
  24. }
  25. -(void)setModel:(LXCalendarDayModel *)model{
  26. _model = model;
  27. self.label.text = [NSString stringWithFormat:@"%ld",model.day];
  28. [self.label setFTCornerdious:0.0];
  29. self.label.backgroundColor = [UIColor whiteColor];
  30. if (model.isNextMonth || model.isLastMonth) {
  31. self.userInteractionEnabled = NO;
  32. if (model.isShowLastAndNextDate) {
  33. self.label.hidden = NO;
  34. if (model.isNextMonth) {
  35. self.label.textColor = model.nextMonthTitleColor? model.nextMonthTitleColor:[UIColor colorWithWhite:0.85 alpha:1.0];
  36. }
  37. if (model.isLastMonth) {
  38. self.label.textColor = model.lastMonthTitleColor? model.lastMonthTitleColor:[UIColor colorWithWhite:0.85 alpha:1.0];
  39. }
  40. }else{
  41. self.label.hidden = YES;
  42. }
  43. }else{
  44. self.label.hidden = NO;
  45. self.userInteractionEnabled = YES;
  46. if (model.isSelected) {
  47. // [self.label setFTCornerdious:self.label.lx_width/2];
  48. self.label.backgroundColor = model.selectBackColor?model.selectBackColor:[UIColor greenColor];
  49. if (model.isHaveAnimation) {
  50. [self addAnimaiton];
  51. }
  52. }
  53. if (model.isSelected) {
  54. self.label.textColor = [UIColor whiteColor];
  55. }else {
  56. self.label.textColor = model.currentMonthTitleColor?model.currentMonthTitleColor:[UIColor hexStringToColor:@"000000"];
  57. }
  58. if (model.isToday) {
  59. self.label.textColor = model.todayTitleColor?model.todayTitleColor:[UIColor redColor];
  60. }
  61. if (model.isToday && model.isSelected) {
  62. self.label.textColor = [UIColor whiteColor];
  63. }
  64. }
  65. }
  66. -(void)addAnimaiton{
  67. CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
  68. anim.values = @[@0.6,@1.2,@1.0];
  69. // anim.fromValue = @0.6;
  70. anim.keyPath = @"transform.scale"; // transform.scale 表示长和宽都缩放
  71. anim.calculationMode = kCAAnimationPaced;
  72. anim.duration = 0.25; // 设置动画执行时间
  73. // anim.repeatCount = MAXFLOAT; // MAXFLOAT 表示动画执行次数为无限次
  74. // anim.autoreverses = YES; // 控制动画反转 默认情况下动画从尺寸1到0的过程中是有动画的,但是从0到1的过程中是没有动画的,设置autoreverses属性可以让尺寸0到1也是有过程的
  75. [self.label.layer addAnimation:anim forKey:nil];
  76. }
  77. @end