ZLProgressHUD.m
1.58 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
//
// ZLProgressHUD.m
// ZLPhotoBrowser
//
// Created by long on 16/2/15.
// Copyright © 2016年 long. All rights reserved.
//
#import "ZLProgressHUD.h"
#import "ZLDefine.h"
@implementation ZLProgressHUD
- (instancetype)init
{
self = [super init];
if (self) {
[self createUI];
}
return self;
}
- (void)createUI
{
self.frame = [UIScreen mainScreen].bounds;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 110, 80)];
view.layer.masksToBounds = YES;
view.layer.cornerRadius = 5.0f;
view.backgroundColor = [UIColor darkGrayColor];
view.alpha = 0.8;
view.center = self.center;
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(40, 15, 30, 30)];
indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[indicator startAnimating];
UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, 110, 30)];
lab.textAlignment = NSTextAlignmentCenter;
lab.textColor = [UIColor whiteColor];
lab.font = [UIFont systemFontOfSize:16];
lab.text = GetLocalLanguageTextValue(ZLPhotoBrowserHandleText);
[view addSubview:indicator];
[view addSubview:lab];
[self addSubview:view];
}
- (void)show
{
[[UIApplication sharedApplication].keyWindow addSubview:self];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(15 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self hide];
});
}
- (void)hide
{
dispatch_async(dispatch_get_main_queue(), ^{
[self removeFromSuperview];
});
}
@end