BGSystemMsgContentCell.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // BGSystemMsgContentCell.m
  3. // BuguLive
  4. //
  5. // Created by bugu on 2019/12/16.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "BGSystemMsgContentCell.h"
  9. #import "UITableViewCell+HYBMasonryAutoCellHeight.h"
  10. @interface BGSystemMsgContentCell ()
  11. @property(nonatomic, strong) UILabel *timeLabel;
  12. @property (nonatomic,strong)UIView *bgView;
  13. @property(nonatomic, strong) UIImageView *bgImageView;
  14. @property(nonatomic, strong) UILabel *titleLabel;
  15. @property(nonatomic, strong) UIView *lineView;
  16. @property(nonatomic, strong) UILabel *contentLabel;
  17. @end
  18. static NSString *const image_name_bg = @"dy_msg_bg";
  19. @implementation BGSystemMsgContentCell
  20. //
  21. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  22. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  23. [self setUpView];
  24. }
  25. return self;
  26. }
  27. -(void)setUpView{
  28. _timeLabel= ({
  29. UILabel * label = [[UILabel alloc]init];
  30. label.textColor = kAppGrayColor1;
  31. label.font = [UIFont systemFontOfSize:16];
  32. label;
  33. });
  34. _bgView=({
  35. UIView *view=[[UIView alloc]init];
  36. view.backgroundColor=kWhiteColor;
  37. view.layer.cornerRadius = 2;
  38. view.layer.shadowColor = [UIColor colorWithRed:207/255.0 green:207/255.0 blue:207/255.0 alpha:0.5].CGColor;
  39. view.layer.shadowOffset = CGSizeMake(0,0);
  40. view.layer.shadowOpacity = 1;
  41. view.layer.shadowRadius = 6;
  42. view;
  43. });
  44. _bgImageView = ({
  45. UIImageView *imageView = [[UIImageView alloc] init];
  46. imageView.image = [UIImage imageNamed:image_name_bg];
  47. imageView.contentMode = UIViewContentModeScaleToFill;
  48. imageView;
  49. });
  50. _titleLabel= ({
  51. UILabel * label = [[UILabel alloc]init];
  52. label.textColor = kAppGrayColor1;
  53. label.font = [UIFont systemFontOfSize:16];
  54. label.numberOfLines = 0;
  55. label;
  56. });
  57. _lineView = ({
  58. UIView * view = [[UIView alloc]init];
  59. view.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
  60. view;
  61. });
  62. _contentLabel= ({
  63. UILabel * label = [[UILabel alloc]init];
  64. label.textColor = kAppGrayColor2;
  65. label.font = [UIFont systemFontOfSize:16];
  66. label.numberOfLines = 0;
  67. label;
  68. });
  69. [self.contentView addSubview:_timeLabel];
  70. [self.contentView addSubview:_bgView];
  71. [_bgView addSubview:_titleLabel];
  72. [_bgView addSubview:_lineView];
  73. [_bgView addSubview:_contentLabel];
  74. self.hyb_lastViewInCell = _bgView;
  75. self.hyb_bottomOffsetToCell = 10;
  76. }
  77. - (void)layoutSubviews {
  78. [super layoutSubviews];
  79. [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.top.mas_equalTo(10);
  81. make.centerX.mas_equalTo(0);
  82. }];
  83. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.top.mas_equalTo(20);
  85. make.left.mas_equalTo(18);
  86. make.centerX.mas_equalTo(0);
  87. }];
  88. [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.top.equalTo(_titleLabel.mas_bottom).offset(8);
  90. make.left.mas_equalTo(18);
  91. make.right.mas_equalTo(-18);
  92. make.height.mas_equalTo(1);
  93. }];
  94. [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.top.equalTo(_lineView.mas_bottom).offset(10);
  96. make.left.mas_equalTo(18);
  97. make.centerX.mas_equalTo(0);
  98. make.bottom.mas_equalTo(-20);
  99. }];
  100. [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.top.equalTo(_timeLabel.mas_bottom).offset(8);
  102. make.left.mas_equalTo(11);
  103. make.centerX.mas_equalTo(0);
  104. }];
  105. }
  106. - (void)setModel:(BGSystemMsgModel *)model{
  107. _timeLabel.text = model.addtime;
  108. _titleLabel.text = model.title;
  109. _contentLabel.text = model.content;
  110. }
  111. @end