LVCRequestFailedView.m
1.94 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
//
// LVCRequestFailedView.m
// LiveVideoCloud
//
// Created by iOS on 17/3/30.
// Copyright © 2017年 cnlive. All rights reserved.
//
#import "LVCRequestFailedView.h"
@interface LVCRequestFailedView ()<UIGestureRecognizerDelegate>
{
NSString *_text;
}
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *textLab;
@property (nonatomic, strong) UITapGestureRecognizer *singleTap; //单击手势
@end
@implementation LVCRequestFailedView
- (instancetype)initWithFrame:(CGRect)frame words:(NSString *)text
{
self = [super initWithFrame:frame];
if (self) {
_text = text;
[self addSubview:self.imageView];
[self addSubview:self.textLab];
[self addGestureRecognizer:self.singleTap];
}
return self;
}
- (void)singleTapView
{
self.hidden = YES;
if (self.delegate && [self.delegate respondsToSelector:@selector(reloadDataWithView:)]) {
[self.delegate reloadDataWithView:self];
}
}
#pragma mark -
#pragma mark - getter
- (UIImageView *)imageView
{
if (!_imageView) {
_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.width-(self.width*0.25)/2, self.height*0.2, self.width*0.25, self.width*0.25)];
_imageView.image = [UIImage imageNamed:@"warn"];
_imageView.center = self.center;
}
return _imageView;
}
- (UILabel *)textLab
{
if (!_textLab) {
_textLab = [[UILabel alloc] initWithFrame:CGRectMake(0, _imageView.bottom+20, self.width, 20)];
_textLab.text = _text;
_textLab.textAlignment = NSTextAlignmentCenter;
_textLab.textColor = [UIColor lightGrayColor];
_textLab.font = [UIFont systemFontOfSize:15];
}
return _textLab;
}
- (UITapGestureRecognizer *)singleTap
{
if (!_singleTap) {
_singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapView)];
_singleTap.delegate = self;
}
return _singleTap;
}
@end