| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- //
- // HJFullTimeTableViewCell.m
- // HappyJob
- //
- // Created by Bob on 2019/3/15.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJFullTimeTableViewCell.h"
- #import "UIButton+HJTagButton.h"
- @interface HJFullTimeTableViewCell () <FBFlowLayoutDelegate, FBFlowLayoutDataSource>
- @end
- @implementation HJFullTimeTableViewCell
- #pragma mark - life cycle
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
-
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
- {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.backgroundColor = COLOR_F5F5F5;
- _edgeInsets = UIEdgeInsetsMake(0, 0, 5, 0);
-
- [self.contentView addSubview:self.bgView];
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.moneyLabel];
- [self.contentView addSubview:self.companyLabel];
- [self.contentView addSubview:self.addressLabel];
- [self.contentView addSubview:self.welfareView];
- [self.contentView addSubview:self.openBtn];
- [self.contentView addSubview:self.maxMoneyLabel];
- [self.contentView addSubview:self.dateLabel];
- [self.contentView addSubview:self.typeIconImageV];
- [self makeConstraints];
- }
- return self;
- }
- - (void)makeConstraints {
-
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.contentView).with.insets(self.edgeInsets);
- }];
- [self.typeIconImageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.offset(0);
- }];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.equalTo(self.bgView).offset(15);
- }];
-
- [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.bgView).offset(-15);
- make.centerY.equalTo(self.titleLabel);
- make.left.greaterThanOrEqualTo(self.titleLabel.mas_right);
- make.width.mas_greaterThanOrEqualTo(120);
- }];
- [self.companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.titleLabel.mas_bottom).with.offset(5);
- make.left.equalTo(self.bgView).offset(15);
- make.right.equalTo(self).offset(-100);
- }];
- [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.companyLabel);
- make.right.equalTo(self.bgView).offset(-15);
- }];
- [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.companyLabel.mas_bottom).offset(5);
- make.left.equalTo(self.companyLabel);
- make.right.equalTo(self.bgView).offset(-15);
- }];
- [self.maxMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.addressLabel.mas_bottom).offset(10);
- make.left.equalTo(self.titleLabel);
- }];
- [self.welfareView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(15);
- make.right.equalTo(self.bgView).offset(-35);
- make.top.equalTo(self.maxMoneyLabel.mas_bottom).offset(10);
- }];
- [self.openBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.welfareView.mas_top).offset(0);
- make.right.equalTo(self.mas_right).offset(-15);
- make.size.mas_offset(CGSizeMake(20, 20));//20
- }];
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.welfareView).offset(20);
- }];
- }
- #pragma mark - CustomDelegate
- - (CGFloat)estimateWidthInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
- //宽
- return (SCREEN_WIDTH - 50);
- }
- - (CGFloat)subviewHorizontalSpacingInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
- //水平间距
- return 5;
- }
- - (CGFloat)subviewVerticalSpacingInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
- //上下间距
- return 6;
- }
- - (NSUInteger)numberInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
- //返回多少个
- return self.welfareTagArray.count;
- }
- - (UIView *)flowLayoutView:(FBFlowLayoutView *)flowLayoutView subviewAtIndex:(NSUInteger)index {
-
- NSString *title = self.welfareTagArray[index];
- UIButton *tagButton = [UIButton hj_createWelfareTagButtonWithTitle:title maxSize:CGSizeMake(flowLayoutView.contentWidth, MAXFLOAT)];
- return tagButton;
- }
- #pragma mark - private methods
- #pragma mark - event respone
- - (void)openBtnClick:(UIButton *)btn {
- self.openBlock();
- }
- #pragma mark - getters and setters
- - (void)setWelfareTagArray:(NSArray *)welfareTagArray {
-
- _welfareTagArray = [welfareTagArray copy];
- [self.welfareView reloadData];
- if (welfareTagArray.count <= 0)
- {
- self.openBtn.hidden = YES;
- }
- else
- {
- self.openBtn.hidden = NO;
- }
- }
- - (void)setHiddenMaxMoneyLabel:(BOOL)hiddenMaxMoneyLabel {
-
- if (hiddenMaxMoneyLabel)
- {
- [self.welfareView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(15);
- make.right.equalTo(self.bgView).offset(-35);
- make.top.equalTo(self.addressLabel.mas_bottom).offset(10);
- }];
- }
- else
- {
- [self.welfareView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(15);
- make.right.equalTo(self.bgView).offset(-35);
- make.top.equalTo(self.maxMoneyLabel.mas_bottom).offset(10);
- }];
- }
- }
- - (UIView *)bgView {
-
- if (_bgView == nil)
- {
- _bgView = [[UIView alloc] init];
- _bgView.backgroundColor = [UIColor whiteColor];
- }
- return _bgView;
- }
- - (UIImageView *)typeIconImageV {
-
- if (_typeIconImageV == nil)
- {
- _typeIconImageV = [[UIImageView alloc]init];
- _typeIconImageV.contentMode = UIViewContentModeScaleAspectFill;
- _typeIconImageV.clipsToBounds = YES;
- }
- return _typeIconImageV;
- }
- - (UIButton *)openBtn {
-
- if (_openBtn == nil)
- {
- _openBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_openBtn addTarget:self action:@selector(openBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _openBtn;
- }
- - (FBFlowLayoutView *)welfareView {
-
- if (_welfareView == nil)
- {
- _welfareView = [[FBFlowLayoutView alloc] init];
- _welfareView.delegate = self;
- _welfareView.dataSource = self;
- }
- return _welfareView;
- }
- - (UILabel *)titleLabel {
-
- if (_titleLabel == nil)
- {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.textColor = COLOR_000000;
- _titleLabel.font = [UIFont boldSystemFontOfSize:19];
- _titleLabel.textAlignment = NSTextAlignmentLeft;
- }
- return _titleLabel;
- }
- - (UILabel *)moneyLabel {
-
- if (_moneyLabel == nil)
- {
- _moneyLabel = [[UILabel alloc] init];
- _moneyLabel.textColor = COLOR_FF401A;
- _moneyLabel.font = [UIFont boldSystemFontOfSize:16];
- _moneyLabel.textAlignment = NSTextAlignmentRight;
- [_moneyLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _moneyLabel;
- }
- - (UILabel *)companyLabel {
-
- if (_companyLabel == nil)
- {
- _companyLabel = [[UILabel alloc] init];
- _companyLabel.textColor = COLOR_444444;
- _companyLabel.font = [UIFont systemFontOfSize:13];
- _companyLabel.textAlignment = NSTextAlignmentLeft;
- [_companyLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _companyLabel;
- }
- - (UILabel *)addressLabel {
-
- if (_addressLabel == nil)
- {
- _addressLabel = [[UILabel alloc] init];
- _addressLabel.textColor = COLOR_444444;
- _addressLabel.font = [UIFont systemFontOfSize:13];
- // _addressLabel.textAlignment = NSTextAlignmentLeft;
- // [_addressLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _addressLabel;
- }
- - (UILabel *)dateLabel {
-
- if (_dateLabel == nil)
- {
- _dateLabel = [[UILabel alloc] init];
- _dateLabel.textColor = COLOR_444444;
- _dateLabel.font = [UIFont systemFontOfSize:13];
- _dateLabel.textAlignment = NSTextAlignmentRight;
- }
- return _dateLabel;
- }
- - (HJMaxMoneyLabel *)maxMoneyLabel {
-
- if (_maxMoneyLabel == nil)
- {
- _maxMoneyLabel = [[HJMaxMoneyLabel alloc] init];
- _maxMoneyLabel.hidden = YES;
- }
- return _maxMoneyLabel;
- }
- @end
|