PlayerFunctionView.m
2.41 KB
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
//
// PlayerFunctionView.m
// CNLiveBKLiveSDKDemo
//
// Created by iOS on 17/4/5.
// Copyright © 2017年 zhulin. All rights reserved.
//
#import "PlayerFunctionView.h"
#import "UIView+Extension.h"
@implementation PlayerFunctionView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
[self addSubview:self.playOrPauseBtn];
[self addSubview:self.currentTimeLabel];
[self addSubview:self.timeSlide];
[self addSubview:self.durationLabel];
}
return self;
}
- (UIButton *)playOrPauseBtn
{
if (!_playOrPauseBtn) {
_playOrPauseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_playOrPauseBtn.frame = CGRectMake(15, 10, 40, 40);
[_playOrPauseBtn setImage:[UIImage imageNamed:@"start"] forState:UIControlStateNormal];
[_playOrPauseBtn setImage:[UIImage imageNamed:@"suspend"] forState:UIControlStateSelected];
}
return _playOrPauseBtn;
}
- (UISlider *)timeSlide
{
if (!_timeSlide) {
_timeSlide = [[UISlider alloc] initWithFrame:CGRectMake(130, 15, self.frame.size.width-130-80, 30)];
[_timeSlide setThumbImage:[UIImage imageNamed:@"btn_dot"] forState:UIControlStateNormal];
[_timeSlide setMinimumTrackTintColor:[UIColor redColor]];
[_timeSlide setMaximumTrackTintColor:[UIColor whiteColor]];
}
return _timeSlide;
}
- (UILabel *)currentTimeLabel
{
if (!_currentTimeLabel) {
_currentTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(65, 5, 60, 50)];
_currentTimeLabel.textColor = [UIColor whiteColor];
_currentTimeLabel.font = [UIFont systemFontOfSize:13];
[_currentTimeLabel setText:[NSString stringWithFormat:@"00:00:00"]];
}
return _currentTimeLabel;
}
- (UILabel *)durationLabel
{
if (!_durationLabel) {
_durationLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width-60-10, 5, 60, 50)];
_durationLabel.textColor = [UIColor whiteColor];
_durationLabel.font = [UIFont systemFontOfSize:13];
[_durationLabel setText:[NSString stringWithFormat:@"00:00:00"]];
}
return _durationLabel;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end