单军华
2018-03-28 f99cf1d5cc50407394501853be06cb39f38a092c
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
86
87
//
//  IdleDeviceCell.m
//  istanbul
//
//  Created by WindShan on 2017/6/16.
//  Copyright © 2017年 WindShan. All rights reserved.
//
 
#import "IdleDeviceCell.h"
#import "GloriaLabel.h"
 
@interface IdleDeviceCell()
{
    
}
 
@property (nonatomic, strong)     GloriaLabel * deviceName;
@property (nonatomic, strong)     GloriaLabel * deviceStatus;
@property (nonatomic, strong)     UIImageView * imageTag;
@end
 
@implementation IdleDeviceCell
 
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
 
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.deviceName.frame = CGRectMake(20, 10, SCREEN_WIDTH/2, 40);
    self.deviceStatus.frame = CGRectMake(20+SCREEN_WIDTH/2+24+10, 10, SCREEN_WIDTH/2, 40);
    self.imageTag.frame = CGRectMake(20+SCREEN_WIDTH/2, 18, 24, 24);
}
 
- (UIImageView *)imageTag
{
    if (!_imageTag)
    {
        _imageTag =  [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 60)];
        [self.contentView addSubview:_imageTag];
    }
    
    return _imageTag;
}
 
- (GloriaLabel *) deviceName
{
    if(!_deviceName)
    {
        _deviceName = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
        _deviceName.font = [UIFont systemFontOfSize:16];
        _deviceName.textAlignment = UITextAlignmentLeft;
        _deviceName.textColor = kUIColorFromRGB(0xa9a9a9);
        [self.contentView addSubview:_deviceName];
    }
    
    return _deviceName;
}
 
- (GloriaLabel *) deviceStatus
{
    if(!_deviceStatus)
    {
        _deviceStatus = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
        _deviceStatus.font = [UIFont systemFontOfSize:16];
        _deviceStatus.textAlignment = UITextAlignmentLeft;
        _deviceStatus.textColor = kUIColorFromRGB(0x5a5a5a);
        [self.contentView addSubview:_deviceStatus];
    }
    
    return _deviceStatus;
}
 
- (void)setItemView:(DeviceSpareModel*)model
{
    self.imageTag.image = [UIImage imageNamed:model.status == 0?@"spare1":@"spare2"];
    [self.deviceName setText:model.name];
    [self.deviceStatus setText:model.status == 0?@"闲置":@"使用"];
}
 
@end