-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmallActivityIndicator.m
More file actions
91 lines (78 loc) · 1.92 KB
/
SmallActivityIndicator.m
File metadata and controls
91 lines (78 loc) · 1.92 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
//
// SmallActivityIndicator.m
//
// Created by Tom Nys on 23/03/11.
// Copyright 2011 Netwalk VOF. All rights reserved.
//
#import "SmallActivityIndicator.h"
#import <QuartzCore/QuartzCore.h>
@implementation SmallActivityIndicator
static SmallActivityIndicator* globalSmallActivityIndicator;
-(void)show:(NSString*)lbl inView:(UIView*)v
{
superview = [v retain];
if (superview)
{
label.text = lbl;
if (!isVisible)
{
[superview addSubview:label];
label.frame = CGRectMake(0, v.bounds.size.height + 10, v.bounds.size.width, 20);
[UIView animateWithDuration:0.5
animations:^(void) {
CGRect fr = label.frame;
fr.origin.y -= 30;
label.frame = fr;
}
completion:^(BOOL finished) {
isVisible = YES;
}];
}
}
}
-(void)hide
{
if (superview)
{
float delay = 0.0;
if (!isVisible)
delay = 0.5;
[UIView animateWithDuration:0.5
delay:delay
options:0
animations:^(void) {
CGRect fr = label.frame;
fr.origin.y += 30;
label.frame = fr;
}
completion:^(BOOL finished) {
[label removeFromSuperview];
}];
[superview release];
superview = nil;
isVisible = NO;
}
}
- (id) init
{
self = [super init];
if (self != nil) {
label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
label.backgroundColor = [UIColor blackColor];
label.textColor = [UIColor whiteColor];
label.layer.masksToBounds = NO;
label.font = [UIFont fontWithName:@"Thonburi" size:14.0];
label.textAlignment = UITextAlignmentCenter;
label.layer.shadowOffset = CGSizeMake(0, -10);
label.layer.shadowRadius = 5;
label.layer.shadowOpacity = 0.5;
label.clipsToBounds = NO;
}
return self;
}
+ (SmallActivityIndicator *)instance {
if (!globalSmallActivityIndicator)
globalSmallActivityIndicator = [[SmallActivityIndicator alloc] init];
return globalSmallActivityIndicator;
}
@end