BHomeListCell.m 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. //
  2. // BHomeCell.m
  3. // HappyJob
  4. //
  5. // Created by 张晓光 on 2019/7/2.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "BHomeListCell.h"
  9. #import "BHomeListModel.h"
  10. @interface BHomeListCell ()
  11. @property (nonatomic, strong) UIView *bgView;
  12. @property (nonatomic, strong) UIView *lineView;
  13. @end
  14. @implementation BHomeListCell
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. }
  19. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  20. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
  21. {
  22. self.selectionStyle = UITableViewCellSelectionStyleNone;
  23. self.backgroundColor = COLOR_GRAYFA;
  24. [self initViews];
  25. [self autoLayOutViews];
  26. }
  27. return self;
  28. }
  29. - (void)initViews {
  30. [self.contentView addSubview:self.bgView];
  31. [self.bgView addSubview:self.headerImageV];
  32. [self.bgView addSubview:self.iconImageV];
  33. [self.bgView addSubview:self.nameLabel];
  34. [self.bgView addSubview:self.jobsLabel];
  35. [self.bgView addSubview:self.positionLabel];
  36. [self.bgView addSubview:self.timeLabel];
  37. [self.bgView addSubview:self.lineView];
  38. }
  39. #pragma mark - 布局
  40. - (void)autoLayOutViews {
  41. __weak typeof(self) weakSelf = self;
  42. [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.leading.equalTo(weakSelf.contentView.mas_leading).offset(0);
  44. make.trailing.equalTo(weakSelf.contentView.mas_trailing).offset(0);
  45. make.top.equalTo(weakSelf.contentView.mas_top).offset(0);
  46. make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(0);
  47. }];
  48. [_headerImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.leading.equalTo(weakSelf.bgView.mas_leading).offset(15);
  50. make.top.equalTo(weakSelf.bgView.mas_top).offset(20);
  51. make.bottom.equalTo(weakSelf.bgView.mas_bottom).offset(-20);
  52. make.size.mas_offset(CGSizeMake(50, 50));
  53. }];
  54. _headerImageV.layer.cornerRadius = 50/2;
  55. _headerImageV.layer.masksToBounds = YES;
  56. [_iconImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.leading.equalTo(weakSelf.headerImageV.mas_leading).offset(38);
  58. make.bottom.equalTo(weakSelf.headerImageV.mas_bottom).offset(0);
  59. make.size.mas_offset(CGSizeMake(12, 12));
  60. }];
  61. [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.leading.equalTo(weakSelf.headerImageV.mas_trailing).offset(20);
  63. make.top.equalTo(weakSelf.bgView.mas_top).offset(20);
  64. make.trailing.equalTo(weakSelf.timeLabel.mas_leading).offset(-5);
  65. }];
  66. [_jobsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.leading.equalTo(weakSelf.nameLabel.mas_trailing).offset(0);
  68. make.bottom.equalTo(weakSelf.nameLabel.mas_bottom).offset(0);
  69. }];
  70. [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.trailing.equalTo(weakSelf.bgView.mas_trailing).offset(-15);
  72. make.centerY.equalTo(weakSelf.nameLabel);
  73. }];
  74. [_positionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.leading.equalTo(weakSelf.headerImageV.mas_trailing).offset(20);
  76. make.bottom.equalTo(weakSelf.bgView.mas_bottom).offset(-20);
  77. make.trailing.equalTo(weakSelf.bgView.mas_trailing).offset(-15);
  78. }];
  79. [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.trailing.equalTo(weakSelf.bgView.mas_trailing).offset(0);
  81. make.leading.equalTo(weakSelf.bgView.mas_leading).offset(0);
  82. make.bottom.equalTo(weakSelf.bgView.mas_bottom).offset(0);
  83. make.height.mas_equalTo(1);
  84. }];
  85. }
  86. #pragma mark - setter&getter
  87. - (UIView *)bgView {
  88. if (_bgView == nil)
  89. {
  90. _bgView = [[UIView alloc]init];
  91. _bgView.backgroundColor = [UIColor whiteColor];
  92. }
  93. return _bgView;
  94. }
  95. - (UIImageView *)headerImageV {
  96. if (_headerImageV == nil)
  97. {
  98. _headerImageV = [[UIImageView alloc]init];
  99. _headerImageV.contentMode = UIViewContentModeScaleAspectFill;
  100. _headerImageV.clipsToBounds = YES;
  101. }
  102. return _headerImageV;
  103. }
  104. - (UIImageView *)iconImageV {
  105. if (_iconImageV == nil)
  106. {
  107. _iconImageV = [[UIImageView alloc]init];
  108. _iconImageV.contentMode = UIViewContentModeScaleAspectFit;
  109. _iconImageV.image = [UIImage imageNamed:@"b_certification"];
  110. }
  111. return _iconImageV;
  112. }
  113. - (UILabel *)nameLabel {
  114. if (_nameLabel == nil)
  115. {
  116. _nameLabel = [[UILabel alloc]init];
  117. _nameLabel.font = [UIFont systemFontOfSize:14];
  118. _nameLabel.textColor = COLOR_BACK3;
  119. }
  120. return _nameLabel;
  121. }
  122. - (UILabel *)jobsLabel {
  123. if (_jobsLabel == nil)
  124. {
  125. _jobsLabel = [[UILabel alloc]init];
  126. _jobsLabel.font = [UIFont systemFontOfSize:14];
  127. _jobsLabel.textColor = COLOR_BACK3;
  128. // _jobsLabel.numberOfLines = 1;
  129. }
  130. return _jobsLabel;
  131. }
  132. - (UILabel *)positionLabel {
  133. if (_positionLabel == nil)
  134. {
  135. _positionLabel = [[UILabel alloc]init];
  136. _positionLabel.font = [UIFont systemFontOfSize:14];
  137. _positionLabel.textColor = COLOR_BACK6;
  138. _positionLabel.numberOfLines = 1;
  139. _positionLabel.textAlignment = NSTextAlignmentLeft;
  140. }
  141. return _positionLabel;
  142. }
  143. - (UILabel *)timeLabel {
  144. if (_timeLabel == nil)
  145. {
  146. _timeLabel = [[UILabel alloc]init];
  147. _timeLabel.font = [UIFont systemFontOfSize:11];
  148. _timeLabel.textColor = COLOR_BACKC;
  149. _timeLabel.textAlignment = NSTextAlignmentRight;
  150. [_timeLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  151. }
  152. return _timeLabel;
  153. }
  154. - (UIView *)lineView {
  155. if (_lineView == nil)
  156. {
  157. _lineView = [[UIView alloc]init];
  158. _lineView.backgroundColor = COLOR_BACKE;
  159. }
  160. return _lineView;
  161. }
  162. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  163. [super setSelected:selected animated:animated];
  164. // Configure the view for the selected state
  165. }
  166. @end