BackgroundView.m
1.55 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
//
// BackgroundView.m
// QNLiveStreamingDemo
//
// Created by iOS on 17/4/7.
// Copyright © 2017年 zhulin. All rights reserved.
//
#import "BackgroundView.h"
@interface BackgroundView ()
@property (nonatomic, strong) UILabel *anchorLab;
@end
@implementation BackgroundView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor blackColor];
[self addSubview:self.anchorLab];
}
return self;
}
- (void)setAnchorStatus:(int)anchorStatus
{
switch (anchorStatus) {
case 0:
self.hidden = YES;
break;
case 1:
_anchorLab.text = @"主播已离开,马上回来~";
self.hidden = NO;
break;
case 2:
_anchorLab.text = @"直播已结束";
self.hidden = NO;
break;
default:
break;
}
}
#pragma mark -
#pragma mark - getter
- (UILabel *)anchorLab
{
if (!_anchorLab) {
_anchorLab = [[UILabel alloc] initWithFrame:CGRectMake(0, self.bounds.size.height/2-25, self.bounds.size.width, 40)];
_anchorLab.textColor = [UIColor whiteColor];
_anchorLab.font = [UIFont systemFontOfSize:22];
_anchorLab.textAlignment = NSTextAlignmentCenter;
}
return _anchorLab;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end