YBDayTaskCell.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // YBDayTaskCell.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2020/10/9.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "YBDayTaskCell.h"
  9. @implementation YBDayTaskCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. +(YBDayTaskCell*)cellWithTab:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath {
  15. YBDayTaskCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YBDayTaskCell"];
  16. if (!cell) {
  17. cell = [[[NSBundle mainBundle]loadNibNamed:@"YBDayTaskCell" owner:nil options:nil]objectAtIndex:0];
  18. }
  19. return cell;
  20. }
  21. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  22. [super setSelected:selected animated:animated];
  23. // Configure the view for the selected state
  24. }
  25. -(void)setDataDic:(NSDictionary *)dataDic
  26. {
  27. _dataDic = dataDic;
  28. // state 0代表未达标 1代表可领取 2代表已领取
  29. self.titleLb.text = minstr([dataDic valueForKey:@"title"]);
  30. self.contentLb.text = minstr([dataDic valueForKey:@"tip_m"]);
  31. if ([minstr([dataDic valueForKey:@"state"]) isEqual:@"0"]) {
  32. [self.stateBtn setTitle:YZMsg(@"未达成") forState:0];
  33. [self.stateBtn setTitleColor:RGB_COLOR(@"#cdcdcd", 1) forState:0];
  34. [self.contentView layoutIfNeeded];
  35. [PublicObj addGradientWithFromColor:RGB_COLOR(@"#000000", 0) andEndColor:RGB_COLOR(@"#000000", 0) andView:self.stateBtn direction:1];
  36. self.stateBtn.userInteractionEnabled = NO;
  37. }else if ([minstr([dataDic valueForKey:@"state"]) isEqual:@"1"]){
  38. [self.stateBtn setTitle:YZMsg(@"可领取") forState:0];
  39. [self.stateBtn setTitleColor:RGB_COLOR(@"#ffffff", 1) forState:0];
  40. [self.contentView layoutIfNeeded];
  41. [PublicObj addGradientWithFromColor:RGB_COLOR(@"#cb16e1", 1) andEndColor:RGB_COLOR(@"#872ae7", 1) andView:self.stateBtn direction:1];
  42. self.stateBtn.userInteractionEnabled = YES;
  43. }else if ([minstr([dataDic valueForKey:@"state"]) isEqual:@"2"]){
  44. [self.stateBtn setTitle:YZMsg(@"已领取") forState:0];
  45. [self.stateBtn setTitleColor:RGB_COLOR(@"#ffffff", 1) forState:0];
  46. [self.contentView layoutIfNeeded];
  47. [PublicObj addGradientWithFromColor:RGB_COLOR(@"#e3e2e2", 1) andEndColor:RGB_COLOR(@"#cacaca", 1) andView:self.stateBtn direction:1];
  48. self.stateBtn.userInteractionEnabled = NO;
  49. }
  50. }
  51. - (IBAction)stateBtnClick:(UIButton *)sender {
  52. if ([self.delegate respondsToSelector:@selector(stateBtnClick:)]) {
  53. [self.delegate stateBtnClick:_dataDic];
  54. }
  55. }
  56. @end