| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- //
- // BHomeCell.m
- // HappyJob
- //
- // Created by 张晓光 on 2019/7/2.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "BHomeListCell.h"
- #import "BHomeListModel.h"
- @interface BHomeListCell ()
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, strong) UIView *lineView;
- @end
- @implementation BHomeListCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
-
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
- {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.backgroundColor = COLOR_GRAYFA;
- [self initViews];
- [self autoLayOutViews];
- }
- return self;
- }
- - (void)initViews {
-
- [self.contentView addSubview:self.bgView];
- [self.bgView addSubview:self.headerImageV];
- [self.bgView addSubview:self.iconImageV];
- [self.bgView addSubview:self.nameLabel];
- [self.bgView addSubview:self.jobsLabel];
- [self.bgView addSubview:self.positionLabel];
- [self.bgView addSubview:self.timeLabel];
- [self.bgView addSubview:self.lineView];
-
- }
- #pragma mark - 布局
- - (void)autoLayOutViews {
-
- __weak typeof(self) weakSelf = self;
- [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.leading.equalTo(weakSelf.contentView.mas_leading).offset(0);
- make.trailing.equalTo(weakSelf.contentView.mas_trailing).offset(0);
- make.top.equalTo(weakSelf.contentView.mas_top).offset(0);
- make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(0);
- }];
- [_headerImageV mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.leading.equalTo(weakSelf.bgView.mas_leading).offset(15);
- make.top.equalTo(weakSelf.bgView.mas_top).offset(20);
- make.bottom.equalTo(weakSelf.bgView.mas_bottom).offset(-20);
- make.size.mas_offset(CGSizeMake(50, 50));
- }];
- _headerImageV.layer.cornerRadius = 50/2;
- _headerImageV.layer.masksToBounds = YES;
-
- [_iconImageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.headerImageV.mas_leading).offset(38);
- make.bottom.equalTo(weakSelf.headerImageV.mas_bottom).offset(0);
- make.size.mas_offset(CGSizeMake(12, 12));
- }];
- [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.headerImageV.mas_trailing).offset(20);
- make.top.equalTo(weakSelf.bgView.mas_top).offset(20);
- make.trailing.equalTo(weakSelf.timeLabel.mas_leading).offset(-5);
- }];
-
- [_jobsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.nameLabel.mas_trailing).offset(0);
- make.bottom.equalTo(weakSelf.nameLabel.mas_bottom).offset(0);
- }];
- [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.trailing.equalTo(weakSelf.bgView.mas_trailing).offset(-15);
- make.centerY.equalTo(weakSelf.nameLabel);
- }];
- [_positionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.headerImageV.mas_trailing).offset(20);
- make.bottom.equalTo(weakSelf.bgView.mas_bottom).offset(-20);
- make.trailing.equalTo(weakSelf.bgView.mas_trailing).offset(-15);
- }];
- [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.trailing.equalTo(weakSelf.bgView.mas_trailing).offset(0);
- make.leading.equalTo(weakSelf.bgView.mas_leading).offset(0);
- make.bottom.equalTo(weakSelf.bgView.mas_bottom).offset(0);
- make.height.mas_equalTo(1);
- }];
-
- }
- #pragma mark - setter&getter
- - (UIView *)bgView {
-
- if (_bgView == nil)
- {
- _bgView = [[UIView alloc]init];
- _bgView.backgroundColor = [UIColor whiteColor];
- }
- return _bgView;
- }
- - (UIImageView *)headerImageV {
-
- if (_headerImageV == nil)
- {
- _headerImageV = [[UIImageView alloc]init];
- _headerImageV.contentMode = UIViewContentModeScaleAspectFill;
- _headerImageV.clipsToBounds = YES;
- }
- return _headerImageV;
- }
- - (UIImageView *)iconImageV {
-
- if (_iconImageV == nil)
- {
- _iconImageV = [[UIImageView alloc]init];
- _iconImageV.contentMode = UIViewContentModeScaleAspectFit;
- _iconImageV.image = [UIImage imageNamed:@"b_certification"];
- }
- return _iconImageV;
- }
- - (UILabel *)nameLabel {
-
- if (_nameLabel == nil)
- {
- _nameLabel = [[UILabel alloc]init];
- _nameLabel.font = [UIFont systemFontOfSize:14];
- _nameLabel.textColor = COLOR_BACK3;
-
- }
- return _nameLabel;
- }
- - (UILabel *)jobsLabel {
-
- if (_jobsLabel == nil)
- {
- _jobsLabel = [[UILabel alloc]init];
- _jobsLabel.font = [UIFont systemFontOfSize:14];
- _jobsLabel.textColor = COLOR_BACK3;
- // _jobsLabel.numberOfLines = 1;
- }
- return _jobsLabel;
- }
- - (UILabel *)positionLabel {
-
- if (_positionLabel == nil)
- {
- _positionLabel = [[UILabel alloc]init];
- _positionLabel.font = [UIFont systemFontOfSize:14];
- _positionLabel.textColor = COLOR_BACK6;
- _positionLabel.numberOfLines = 1;
- _positionLabel.textAlignment = NSTextAlignmentLeft;
- }
- return _positionLabel;
- }
- - (UILabel *)timeLabel {
-
- if (_timeLabel == nil)
- {
- _timeLabel = [[UILabel alloc]init];
- _timeLabel.font = [UIFont systemFontOfSize:11];
- _timeLabel.textColor = COLOR_BACKC;
- _timeLabel.textAlignment = NSTextAlignmentRight;
- [_timeLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
-
- }
- return _timeLabel;
- }
- - (UIView *)lineView {
-
- if (_lineView == nil)
- {
- _lineView = [[UIView alloc]init];
- _lineView.backgroundColor = COLOR_BACKE;
- }
- return _lineView;
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|