MGSignCollectCell.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // MGSignCollectCell.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2019/12/21.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "MGSignCollectCell.h"
  9. @interface MGSignCollectCell ()
  10. @property(nonatomic, strong) UIView *layerView;
  11. @property(nonatomic, strong) UILabel *dayLabel;
  12. @property(nonatomic, strong) UIImageView *giftImageView;
  13. @property(nonatomic, strong) UILabel *scoreLabel;
  14. @end
  15. @implementation MGSignCollectCell
  16. - (instancetype)initWithFrame:(CGRect)frame {
  17. self = [super initWithFrame:frame];
  18. if (self) {
  19. [self initUI];
  20. self.backgroundColor = kWhiteColor;
  21. }
  22. return self;
  23. }
  24. - (void)initUI{
  25. _layerView = ({
  26. UIView *view = [[UIView alloc] init];
  27. view.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor;
  28. view.layer.cornerRadius = 5;
  29. view.layer.shadowColor = [UIColor colorWithRed:198/255.0 green:198/255.0 blue:198/255.0 alpha:0.5].CGColor;
  30. view.layer.shadowOffset = CGSizeMake(0,0);
  31. view.layer.shadowOpacity = 1;
  32. view.layer.shadowRadius = 4;
  33. view;
  34. });
  35. [self addSubview:_layerView];
  36. _dayLabel= ({
  37. UILabel * label = [[UILabel alloc]init];
  38. label.textColor = [UIColor colorWithHexString:@"#999999"];
  39. label.font = [UIFont systemFontOfSize:10];
  40. label.text = ASLocalizedString(@"第1天");
  41. label;
  42. });
  43. _giftImageView = ({
  44. UIImageView *imageView = [[UIImageView alloc] init];
  45. imageView.image = [UIImage imageNamed:@"礼物"];
  46. imageView;
  47. });
  48. _scoreLabel= ({
  49. UILabel * label = [[UILabel alloc]init];
  50. label.textColor = [UIColor colorWithHexString:@"#CD49FF"];
  51. label.font = [UIFont systemFontOfSize:12];
  52. label.text = @"+1";
  53. label;
  54. });
  55. [_layerView addSubview:_dayLabel];
  56. [_layerView addSubview:_giftImageView];
  57. [_layerView addSubview:_scoreLabel];
  58. }
  59. - (void)layoutSubviews {
  60. [super layoutSubviews];
  61. [_layerView mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.edges.equalTo(self).insets(UIEdgeInsetsMake(5, 0, 10, 0));
  63. }];
  64. [_dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.mas_equalTo(5);
  66. make.centerX.equalTo(_layerView);
  67. }];
  68. [_giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.top.equalTo(_dayLabel.mas_bottom).offset(7);
  70. make.centerX.equalTo(_dayLabel);
  71. make.width.height.mas_equalTo(22);
  72. }];
  73. [_scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.bottom.mas_equalTo(-5);
  75. make.centerX.equalTo(_dayLabel);
  76. }];
  77. }
  78. - (void)setModel:(BGSignRewardModel *)model{
  79. _dayLabel.text = [NSString stringWithFormat:ASLocalizedString(@"第%@天"),model.day];
  80. _scoreLabel.text = [NSString stringWithFormat:@"+%@",model.num];
  81. self.alreadySign = model.is_sign.intValue;
  82. }
  83. - (void)setAlreadySign:(BOOL)alreadySign{
  84. if (alreadySign) {
  85. _layerView.backgroundColor = [UIColor colorWithHexString:@"E5E5E5"];
  86. } else {
  87. _layerView.backgroundColor = [UIColor whiteColor];
  88. }
  89. }
  90. @end