单军华
2018-03-29 89d748b77b478905732e60f0b4c5807c274b6565
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
//
//  SearchDeviceCell.m
//  istanbul
//
//  Created by WindShan on 2017/6/16.
//  Copyright © 2017年 WindShan. All rights reserved.
//
 
#import "SearchDeviceCell.h"
#import "GloriaLabel.h"
 
@interface SearchDeviceCell()
{
    
}
 
@property (nonatomic, strong)     GloriaLabel * deviceName;
@property (nonatomic, strong)     GloriaLabel * deviceLink;
@property (nonatomic, strong)     UIImageView * imageTag;
@end
 
@implementation SearchDeviceCell
 
/*
// 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+20, 10, SCREEN_WIDTH/2, 20);
    self.deviceLink.frame = CGRectMake(SCREEN_WIDTH-100-20, 10, 100, 20);
    self.imageTag.frame = CGRectMake(20, 15, 10, 10);
}
 
- (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 *) deviceLink
{
    if(!_deviceLink)
    {
        _deviceLink = [[GloriaLabel alloc] initWithFrame:CGRectMake(10+50+10+80, 28,150, 14)];
        _deviceLink.font = [UIFont systemFontOfSize:16];
        _deviceLink.textAlignment = UITextAlignmentRight;
        _deviceLink.textColor = [UIColor redColor];
        [self.contentView addSubview:_deviceLink];
    }
    
    return _deviceLink;
}
 
- (void)setItemView:(NSString *) bleName
{
    self.imageTag.image = [UIImage imageNamed:@"icon_lanya_tag"];
    [self.deviceName setText:bleName];
    [self.deviceLink setText:@"链接 >"];
}
 
@end