1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
//  PBEditPersonCollectionViewCell.m
//  IphoneBIMe
//
//  Created by zjf on 2018/8/17.
//  Copyright © 2018年 ProBIM. All rights reserved.
//
 
#import "PBEditPersonCollectionViewCell.h"
@interface PBEditPersonCollectionViewCell()
@property (nonatomic, weak) UILabel *personNameL;
@property (nonatomic, weak) UIButton *deleteBtn;
@end
@implementation PBEditPersonCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    self.contentView.backgroundColor = [UIColor z_colorWithR:255 G:170 B:0 alpha:0.12];
    UILabel *personNameL = [UILabel z_labelWithText:@"" Color:WarningColor isBold:NO Font:12];
    personNameL.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:personNameL];
    [personNameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(6);
        make.bottom.equalTo(self.contentView).offset(-6);
        make.left.equalTo(self.contentView).offset(8);
        make.right.equalTo(self.contentView).offset(-26);
    }];
    UIButton *deleteBtn = [UIButton z_bgImageButton:[UIImage imageNamed:@"Issue_editPerson_delete"]];
    [deleteBtn addTarget:self action:@selector(deleteBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:deleteBtn];
    [deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.equalTo(self.contentView);
        make.width.equalTo(@26);
    }];
 
    self.personNameL = personNameL;
    self.deleteBtn = deleteBtn;
}
- (void)setIsHiddenDelete:(BOOL)isHiddenDelete {
    _isHiddenDelete = isHiddenDelete;
}
- (void)setName:(NSString *)name {
    _name = name;
    self.personNameL.text = name;
    if (self.isHiddenDelete) {
        self.deleteBtn.hidden = YES;
    }else {
        self.deleteBtn.hidden = NO;
    }
}
 
- (void)deleteBtnAction {
    if (self.deletePersonBlock) {
        self.deletePersonBlock();
    }
}
@end