SPSBMineMessageTableViewCell.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // SPSBMineMessageTableViewCell.m
  3. // 我的社保
  4. //
  5. // Created by shanp on 2021/5/21.
  6. //
  7. #import "SPSBMineMessageTableViewCell.h"
  8. #import "SPSBUIGeneralHeader.h"
  9. #import <CALayer+JXHShadow.h>
  10. #import "SPSBMineMessageModel.h"
  11. @interface SPSBMineMessageTableViewCell () {
  12. UILabel *_timeLabel;
  13. UILabel *_titleLabel;
  14. UILabel *_contentLabel;
  15. UIView *_contentBgView;
  16. }
  17. @end
  18. @implementation SPSBMineMessageTableViewCell
  19. + (SPSBMineMessageTableViewCell *)creatFirstCell {
  20. SPSBMineMessageTableViewCell *cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
  21. UIView *bannerBg = UIView.new;
  22. bannerBg.backgroundColor = spsb_FFFFFF_color(1.f);
  23. [bannerBg setLayerCornerRadius:4 clipToBounds:true];
  24. [cell->_contentBgView addSubview:bannerBg];
  25. [bannerBg makeConstraints:^(JXHConstraintMaker *make) {
  26. make.top.and.leading.and.trailing.equalTo(0);
  27. make.height.equalTo((jxh_screenWidth() - 30) * 0.35 + 20);
  28. }];
  29. UIImageView *banner = [[UIImageView alloc] initWithImage:jxh_getImage(notice_banner)];
  30. [bannerBg addSubview:banner];
  31. [banner makeConstraints:^(JXHConstraintMaker *make) {
  32. make.top.and.left.and.right.equalTo(0);
  33. make.height.equalTo((jxh_screenWidth() - 30) * 0.35);
  34. }];
  35. [cell->_titleLabel remakeConstraints:^(JXHConstraintMaker *make) {
  36. make.leading.equalTo(20);
  37. make.trailing.equalTo(-20);
  38. make.top.equalTo(bannerBg.bottom);
  39. }];
  40. return cell;
  41. }
  42. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  43. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  44. if (!self) return nil;
  45. self.selectionStyle = UITableViewCellSelectionStyleNone;
  46. self.backgroundColor = spsb_F5F5F5_color();
  47. _timeLabel = [UILabel convenienceWithFont:spsb_font(13) text:@"" textColor:spsb_FFFFFF_color(1.f) textAlignment:NSTextAlignmentCenter];
  48. [_timeLabel setLayerCornerRadius:12 clipToBounds:true];
  49. _timeLabel.backgroundColor = spsb_000000_color(0.15);
  50. [self.contentView addSubview:_timeLabel];
  51. [_timeLabel makeConstraints:^(JXHConstraintMaker *make) {
  52. make.centerX.equalTo(self.contentView);
  53. make.top.equalTo(0);
  54. make.size.equalTo(CGSizeMake(150, 25));
  55. }];
  56. _contentBgView = UIView.new;
  57. _contentBgView.backgroundColor = spsb_FFFFFF_color(1.f);
  58. [self.contentView addSubview:_contentBgView];
  59. [_contentBgView makeConstraints:^(JXHConstraintMaker *make) {
  60. make.top.equalTo(40);
  61. make.leading.equalTo(15);
  62. make.bottom.equalTo(-30);
  63. make.trailing.equalTo(-15);
  64. }];
  65. _titleLabel = [UILabel convenienceWithFont:spsb_semiboldFont(17) text:@"" textColor:spsb_333333_color()];
  66. [_contentBgView addSubview:_titleLabel];
  67. [_titleLabel makeConstraints:^(JXHConstraintMaker *make) {
  68. make.leading.equalTo(20);
  69. make.trailing.equalTo(-20);
  70. make.top.equalTo(21);
  71. }];
  72. _contentLabel = [UILabel convenienceWithFont:spsb_font(16) text:@"" textColor:spsb_666666_color()];
  73. [_contentBgView addSubview:_contentLabel];
  74. [_contentLabel makeConstraints:^(JXHConstraintMaker *make) {
  75. make.leading.equalTo(20);
  76. make.trailing.equalTo(-20);
  77. make.top.equalTo(self->_titleLabel.bottom).offset(15);
  78. make.bottom.equalTo(-24);
  79. }];
  80. return self;
  81. }
  82. - (void)reloadData:(SPSBMineMessageModel *)data {
  83. _timeLabel.text = data.spsb_time;
  84. [_titleLabel setAttributedStringWithText:data.spsb_title lineSpacing:3];
  85. [_contentLabel setAttributedStringWithText:data.spsb_content lineSpacing:4];
  86. }
  87. - (void)layoutSubviews {
  88. [super layoutSubviews];
  89. [_contentBgView.layer setShadowWithOffset:(CGSize){0, 2} alpha:0.03 blur:4 spread:0 color:spsb_FFFFFF_color(1.f) cornerRadius:4 pathRect:(CGRect){0, 0, jxh_screenWidth() - 30, jxh_viewHeight(self.contentView) - 70}];
  90. }
  91. @end