USADAKAWorkOutCollectionCell.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // USADAKAWorkOutCollectionCell.m
  3. // shiku_im
  4. //
  5. // Created by liyangyang-pc on 2018/5/17.
  6. //
  7. #import "USADAKAWorkOutCollectionCell.h"
  8. @interface USADAKAWorkOutCollectionCell()
  9. @property (strong , nonatomic) UILabel *nameLabel;
  10. @property (strong , nonatomic) UIButton *shensubtn;
  11. @end
  12. @implementation USADAKAWorkOutCollectionCell
  13. - (instancetype)init
  14. {
  15. self = [super init];
  16. if (self) {
  17. [self createUI];
  18. }
  19. return self;
  20. }
  21. - (instancetype)initWithFrame:(CGRect)frame
  22. {
  23. self = [super initWithFrame:frame];
  24. if (self) {
  25. [self createUI];
  26. }
  27. return self;
  28. }
  29. - (void)createUI{
  30. self.contentView.backgroundColor = [UIColor whiteColor];;
  31. [self.contentView addSubview:self.nameLabel];
  32. [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.top.bottom.equalTo(self.contentView);
  34. make.width.mas_equalTo(40);
  35. }];
  36. [self.contentView addSubview:self.shensubtn];
  37. [self.shensubtn mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.equalTo(self.nameLabel.mas_right).offset(0);
  39. make.top.equalTo(self.contentView).offset(2);
  40. make.width.mas_equalTo(45);
  41. make.height.mas_equalTo(17);
  42. }];
  43. }
  44. -(UILabel *)nameLabel
  45. {
  46. if (!_nameLabel) {
  47. _nameLabel = [[UILabel alloc]init];
  48. _nameLabel.font = FONT_SIZE(14);
  49. _nameLabel.textColor = Color(153, 153, 153, 1.0);
  50. _nameLabel.text = @"旷工";
  51. _nameLabel.backgroundColor = [UIColor whiteColor];
  52. }
  53. return _nameLabel;
  54. }
  55. -(UIButton *)shensubtn
  56. {
  57. if (!_shensubtn) {
  58. _shensubtn = [UIButton buttonWithType:UIButtonTypeCustom];
  59. [_shensubtn setTitle:@"申诉" forState:UIControlStateNormal];
  60. [_shensubtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  61. _shensubtn.titleLabel.font = FONT_SIZE(13);
  62. [_shensubtn setBackgroundColor:Color(51, 168, 238, 1.0) forState:UIControlStateNormal];
  63. [_shensubtn addTarget:self action:@selector(bukaAction:) forControlEvents:UIControlEventTouchUpInside];
  64. _shensubtn.layer.masksToBounds = YES;
  65. _shensubtn.layer.cornerRadius = 8.0f;
  66. }
  67. return _shensubtn;
  68. }
  69. - (void)bukaAction:(UIButton *)sender{
  70. if (self.blcok) {
  71. NSString *str = @"";
  72. if (self.shensubtn.tag == 11) {
  73. str = FORMAT(@"%@ %@:00",self.model.date,self.model.wd_onduty);
  74. }else
  75. {
  76. str = FORMAT(@"%@ %@:00",self.model.date,self.model.wd_offduty);
  77. }
  78. self.blcok(str);
  79. }
  80. }
  81. -(void)setModel:(UASDAKAClassModel *)model
  82. {
  83. _model = model;
  84. self.shensubtn.tag = model.indexPath;
  85. if (model.indexPath == 11) {
  86. if (model.onduty_apprecord) {
  87. [self.shensubtn setTitle:@"申诉中" forState:UIControlStateNormal];
  88. [self.shensubtn setUserInteractionEnabled:NO];
  89. [self.shensubtn setBackgroundColor:Color(153, 153, 153, 1.0) forState:UIControlStateNormal];
  90. [self.shensubtn mas_updateConstraints:^(MASConstraintMaker *make) {
  91. make.width.mas_equalTo(48+cellScale);
  92. }];
  93. [self.shensubtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  94. }
  95. }else
  96. {
  97. if (model.offduty_apprecord) {
  98. [self.shensubtn setTitle:@"申诉中" forState:UIControlStateNormal];
  99. [self.shensubtn setUserInteractionEnabled:NO];
  100. [self.shensubtn setBackgroundColor:Color(153, 153, 153, 1.0) forState:UIControlStateNormal];
  101. [self.shensubtn mas_updateConstraints:^(MASConstraintMaker *make) {
  102. make.width.mas_equalTo(48+cellScale);
  103. }];
  104. [self.shensubtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  105. }
  106. }
  107. }
  108. @end