-
Notifications
You must be signed in to change notification settings - Fork 5
/
ISLoadingIndicator.j
46 lines (36 loc) · 965 Bytes
/
ISLoadingIndicator.j
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
/*!
ISLoadingIndicator is a sexy spinny thing.
Created by Randy Luecke on April 28, 2011.
Copyright 2011, RCLConcepts, LLC All rights reserved.
*/
@implementation ISLoadingIndicator : CPView
{
CPTimer spinnerTimer;
CPImageView spinnerSprite;
int step;
}
- (id)initWithFrame:(CGRect)aRect
{
self = [super initWithFrame:aRect];
step = 0;
spinnerSprite = [[CPImageView alloc] initWithFrame:CGRectMake(0,0,358,29)];
[spinnerSprite setImage:resourcesImage("spinnersprite.png", 358, 29)];
[self addSubview:spinnerSprite];
return self;
}
- (void)startAnimating
{
spinnerTimer = [CPTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(setNeedsLayout) userInfo:nil repeats:YES];
}
- (void)stopAnimating
{
[spinnerTimer invalidate]
}
- (void)layoutSubviews
{
step++;
if (step > 11)
step = 0;
[spinnerSprite setFrameOrigin:CGPointMake(step * (-30),0)];
}
@end