JLChen
2021-11-04 1443556e9ccb1a19ed8e6710c16c8adc4d4f4fb3
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
//
//  Copyright © 2020 dahua. All rights reserved.
//
 
#import "LCVideotapeListHeardView.h"
#import "LCUIKit.h"
 
@interface LCVideotapeListHeardView ()
 
/// CAShapeLayer
@property (strong, nonatomic) CAShapeLayer *lineLayer;
 
/// CAShapeLayer
@property (strong, nonatomic) CAShapeLayer *ovalLayer;
 
/// CAShapeLayer
@property (strong, nonatomic) UILabel *timeLab;
 
 
@end
 
@implementation LCVideotapeListHeardView
 
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupView];
        
    }
    return self;
}
 
- (void)setupView {
    self.timeLab = [[UILabel alloc] initWithFrame:CGRectMake(30,0,100, self.bounds.size.height)];
    self.timeLab.textColor = [UIColor dhcolor_c10];
    self.timeLab.font = [UIFont lcFont_t5];
    [self addSubview:self.timeLab];
}
 
- (void)setTime:(NSString *)time {
    _time = time;
    self.timeLab.text = time;
    [self drawLine];
}
 
- (void)drawRect:(CGRect)rect {
    NSLog(@"VIEW_JIA%@",NSStringFromCGRect(rect));
    
}
 
- (void)drawLine {
    // 线的路径
    [self.lineLayer removeFromSuperlayer];
    [self.ovalLayer removeFromSuperlayer];
    //画线条
    UIBezierPath *linePath = [UIBezierPath bezierPath];
    // 起点
    [linePath moveToPoint:CGPointMake(20,self.frame.size.height)];
    if (self.index==0) {
        [linePath addLineToPoint:CGPointMake(20, self.bounds.size.height / 2.0)];
    }else{
        [linePath addLineToPoint:CGPointMake(20, 0)];
    }
    CAShapeLayer *lineLayer = [CAShapeLayer layer];
    lineLayer.lineWidth = 2;
    lineLayer.strokeColor = [UIColor dhcolor_c10].CGColor;
    lineLayer.path = linePath.CGPath;
    self.lineLayer = lineLayer;
    [self.layer addSublayer:lineLayer];
    
    //画圆
    UIBezierPath *ovalPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(15,self.bounds.size.height /2.0 - 5, 10, 10)];
    CAShapeLayer *ovalLayer = [CAShapeLayer layer];
    ovalLayer.lineWidth = 3;
    ovalLayer.fillColor = [UIColor dhcolor_c10].CGColor;
    ovalLayer.strokeColor = [UIColor dhcolor_c20].CGColor;
    ovalLayer.path = ovalPath.CGPath;
    self.ovalLayer = ovalLayer;
    [self.layer addSublayer:ovalLayer];
}
 
 
 
@end