ZZPhotoHud.m
2.16 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// ZZPhotoHud.m
// ZZPhotoKit
//
// Created by Yuan on 16/1/14.
// Copyright © 2016年 Ace. All rights reserved.
//
#import "ZZPhotoHud.h"
@interface ZZPhotoHud()
@property (strong ,nonatomic) UIView *hudView;
@property (strong ,nonatomic) UIActivityIndicatorView *indicatorView;
@property (strong ,nonatomic) UILabel *hudLabel;
@end
@implementation ZZPhotoHud
+(ZZPhotoHud *)sharedHud
{
static ZZPhotoHud *_photoHud = nil;
if (_photoHud == nil) {
_photoHud = [[ZZPhotoHud alloc]init];
}
return _photoHud;
}
-(instancetype)init
{
self = [super init];
if (self) {
}
return self;
}
-(void)show
{
[[UIApplication sharedApplication].keyWindow addSubview:self];
[self makeInitUI];
[self makeHudUI];
}
-(void) makeInitUI
{
//清楚整个背景颜色
self.backgroundColor = [UIColor clearColor];
self.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
}
-(void) makeHudUI
{
_hudView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 120, 90)];
_hudView.center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2, [UIScreen mainScreen].bounds.size.height / 2);
_hudView.layer.cornerRadius = 8;
_hudView.clipsToBounds = YES;
_hudView.backgroundColor = [UIColor blackColor];
_hudView.alpha = 0.8;
[self addSubview:_hudView];
_indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
_indicatorView.frame = CGRectMake(45, 15, 30, 30);
[_hudView addSubview:_indicatorView];
[_indicatorView startAnimating];
_hudLabel = [[UILabel alloc] init];
_hudLabel.frame = CGRectMake(0,40, 120, 50);
_hudLabel.textAlignment = NSTextAlignmentCenter;
_hudLabel.text = @"图片处理中...";
_hudLabel.font = [UIFont systemFontOfSize:15];
_hudLabel.textColor = [UIColor whiteColor];
[_hudView addSubview:_hudLabel];
}
-(void) removeHudUI;
{
[self removeFromSuperview];
[_indicatorView stopAnimating];
}
+(void)showActiveHud
{
[[self sharedHud] show];
}
+(void)hideActiveHud
{
[[self sharedHud] removeHudUI];
}
@end