-
Notifications
You must be signed in to change notification settings - Fork 330
/
JGProgressHUDFadeAnimation.m
executable file
·60 lines (46 loc) · 1.38 KB
/
JGProgressHUDFadeAnimation.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
//
// JGProgressHUDFadeAnimation.m
// JGProgressHUD
//
// Created by Jonas Gessner on 20.7.14.
// Copyright (c) 2014 Jonas Gessner. All rights reserved.
//
#import "JGProgressHUDFadeAnimation.h"
@implementation JGProgressHUDFadeAnimation
#pragma mark - Initializers
- (instancetype)init {
self = [super init];
if (self) {
self.duration = 0.4;
self.animationOptions = UIViewAnimationOptionCurveEaseInOut;
}
return self;
}
- (void)setAnimationOptions:(UIViewAnimationOptions)animationOptions {
_animationOptions = (animationOptions | UIViewAnimationOptionBeginFromCurrentState);
}
#pragma mark - Showing
- (void)show {
[super show];
//Prepare animation
self.progressHUD.alpha = 0.0f;
//Now unhide HUD
self.progressHUD.hidden = NO;
//Perform the presentation animation
[UIView animateWithDuration:self.duration delay:0.0 options:self.animationOptions animations:^{
self.progressHUD.alpha = 1.0f;
} completion:^(BOOL __unused finished) {
[self animationFinished];
}];
}
#pragma mark - Hiding
- (void)hide {
[super hide];
//Perform the dismissal animation
[UIView animateWithDuration:self.duration delay:0.0 options:self.animationOptions animations:^{
self.progressHUD.alpha = 0.0f;
} completion:^(BOOL __unused finished) {
[self animationFinished];
}];
}
@end