-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXSProgress.m
73 lines (53 loc) · 1.41 KB
/
XSProgress.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
//
// XSProgress.m
// XS_iOS_Utility
//
// Created by 肖胜 on 15/9/1.
// Copyright (c) 2015年 肖胜. All rights reserved.
//
#import "XSProgress.h"
static XSProgress *instace = nil;
static int i;
NSTimer *timer;
@implementation XSProgress
+ (XSProgress *)shareInstace {
if (instace == nil) {
instace = [[self alloc]init];
}
return instace;
}
+ (instancetype)allocWithZone:(struct _NSZone *)zone {
if (instace == nil) {
instace = [super allocWithZone:zone];
}
return instace;
}
+ (void)show {
instace = [self shareInstace];
instace.frame = CGRectMake(100, 350, 100, 100);
instace.alpha = 0;
UIWindow *keywindow = [UIApplication sharedApplication].keyWindow;
[UIView animateWithDuration:.5 animations:^{
instace.alpha = 1;
}];
[keywindow addSubview:instace];
timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(annimation) userInfo:nil repeats:YES];
}
+(void)hide {
[UIView animateWithDuration:.5 animations:^{
instace.alpha = 0;
} completion:^(BOOL finished) {
[instace removeFromSuperview];
[timer invalidate];
timer = nil;
instace = nil;
}];
}
+ (void)annimation {
i++;
instace.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d",i]];
if (i == 3) {
i = 0;
}
}
@end