-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIView+MBProgressHUD.m
executable file
·92 lines (82 loc) · 2.55 KB
/
UIView+MBProgressHUD.m
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
//
// UIView+MBProgressHUD.m
//
//
// Created by yjh4866 on 12-12-21.
// Copyright (c) 2013年 yjh4866. All rights reserved.
//
#import "UIView+MBProgressHUD.h"
@implementation UIView (MBProgressHUD)
// 只显示活动指示
- (MBProgressHUD *)showActivity
{
MBProgressHUD *hud = [MBProgressHUD HUDForView:self];
if (nil == hud) {
hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
}
hud.removeFromSuperViewOnHide = YES;
return hud;
}
// 显示活动指示及文本
- (MBProgressHUD *)showActivityWithText:(NSString *)text
{
MBProgressHUD *hud = [MBProgressHUD HUDForView:self];
if (nil == hud) {
hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
}
hud.labelText = text;
hud.removeFromSuperViewOnHide = YES;
return hud;
}
// 移除活动指示
- (void)hideActivity
{
[[MBProgressHUD HUDForView:self] hide:YES];
}
// 不显示活动指示,只显示文本,指定显示时长
- (MBProgressHUD *)showTextNoActivity:(NSString *)text timeLength:(CGFloat)time
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = text;
hud.removeFromSuperViewOnHide = YES;
[hud hide:YES afterDelay:time];
return hud;
}
// 显示文本及指定图片,指定显示时长
- (MBProgressHUD *)showText:(NSString *)text image:(UIImage *)image timeLength:(CGFloat)time
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.labelText = text;
hud.removeFromSuperViewOnHide = YES;
[hud hide:YES afterDelay:time];
//
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
hud.customView = imageView;
[imageView release];
return hud;
}
// 显示文本及指定图片,指定显示时长
- (MBProgressHUD *)showText:(NSString *)text imageName:(NSString *)imageName timeLength:(CGFloat)time
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.labelText = text;
hud.removeFromSuperViewOnHide = YES;
[hud hide:YES afterDelay:time];
//
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
hud.customView = imageView;
[imageView release];
return hud;
}
- (MBProgressHUD *)showProgress:(MBProgressHUDMode)aMode
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
hud.mode = aMode;
hud.removeFromSuperViewOnHide = YES;
return hud;
}
@end