zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
//  PBModelsTableViewCell.m
//  IphoneBIMe
//
//  Created by zjf on 2018/7/20.
//  Copyright © 2018年 ProBIM. All rights reserved.
//
 
#import "PBModelsTableViewCell.h"
#import "PBModelsModel.h"
@interface PBModelsTableViewCell()
@property (nonatomic, weak) UIImageView *modelImageV;
@property (nonatomic, weak) UILabel *modelNameL;
@property (nonatomic, weak) UILabel *timeL;
@end
@implementation PBModelsTableViewCell
 
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    self.contentView.backgroundColor = PBColor(244, 245, 246);
    UIView *bgV = [[UIView alloc] init];
    bgV.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:bgV];
    [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);
        make.bottom.equalTo(self.contentView);
    }];
    [bgV circleViewWithRadius:6];
    
    UIImageView *modelImageV = [[UIImageView alloc] init];
    [self.contentView addSubview:modelImageV];
    [modelImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(bgV).offset(10);
        make.size.mas_equalTo(CGSizeMake(70, 70));
    }];
    [modelImageV circleViewWithRadius:6];
    
    UILabel *modelNameL = [UILabel z_labelWithText:@"" Color:PBColor(40, 58, 79) isBold:YES Font:14];
    modelNameL.numberOfLines = 2;
    [self.contentView addSubview:modelNameL];
    [modelNameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(modelImageV);
        make.left.equalTo(modelImageV.mas_right).offset(10);
        make.right.equalTo(bgV).offset(-10);
    }];
    
    UILabel *timeL = [UILabel z_labelWithText:@"" Color:PBColor(166, 174, 182) isBold:YES Font:13];
    [self.contentView addSubview:timeL];
    [timeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(modelImageV.mas_bottom);
        make.left.right.equalTo(modelNameL);
        make.height.equalTo(@16);
    }];
    self.modelImageV = modelImageV;
    self.modelNameL = modelNameL;
    self.timeL = timeL;
}
- (void)setModelsModel:(PBModelsModel *)modelsModel{
    _modelsModel = modelsModel;
    if([modelsModel.Thumbnail isEqualToString:@""]) {
        self.modelImageV.image = [UIImage imageNamed:@"logo_unknown"];
    }else {
        self.modelImageV.image = [NSString imageDecoding:modelsModel.Thumbnail];
    }
    self.modelNameL.text = modelsModel.Name;
    NSString *timeStr = [modelsModel.CreateTime stringByReplacingOccurrencesOfString:@"T" withString:@" "];
    NSRange range = [timeStr rangeOfString:@":"];
    timeStr = [timeStr substringToIndex:range.location + 3];
    self.timeL.text = timeStr;
}
 
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
 
    // Configure the view for the selected state
}
 
@end