@@ -18,6 +18,12 @@ @interface SCCatWaitingHUD()
18
18
19
19
@property (nonatomic , strong ) UIView *leftEyeCover;
20
20
@property (nonatomic , strong ) UIView *rightEyeCover;
21
+
22
+ /* *
23
+ * Time duration for HUD display and disappear.
24
+ */
25
+ @property (nonatomic ) CGFloat easeInDuration;
26
+
21
27
@end
22
28
23
29
@implementation SCCatWaitingHUD
@@ -37,8 +43,8 @@ - (id)initWithFrame:(CGRect)frame
37
43
self = [super initWithFrame: frame];
38
44
if (self)
39
45
{
40
- self.easeInDuration = 0 . 3f ;
41
- self.animationDuration = 2 . 0f ;
46
+ self.animationDuration = 1 . 5f ;
47
+ self.easeInDuration = self. animationDuration * 0 . 25f ;
42
48
43
49
[[NSNotificationCenter defaultCenter ] addObserver: self
44
50
selector: @selector (statusBarOrientationChange: )
@@ -90,7 +96,7 @@ - (void)initSubViews
90
96
_leftEye.layer .masksToBounds = YES ;
91
97
_leftEye.layer .cornerRadius = 2 .5f ;
92
98
_leftEye.backgroundColor = [UIColor blackColor ];
93
- _leftEye.layer .anchorPoint = CGPointMake (1 .7f , 1 .3f );
99
+ _leftEye.layer .anchorPoint = CGPointMake (1 .5f , 1 .5f );
94
100
_leftEye.layer .position = CGPointMake (self.faceView .left + 13 .5f ,self.faceView .top + width/3 .0f + 7 .5f );
95
101
[_indicatorView addSubview: _leftEye];
96
102
@@ -104,7 +110,7 @@ - (void)initSubViews
104
110
_rightEye.layer .masksToBounds = YES ;
105
111
_rightEye.layer .cornerRadius = 2 .5f ;
106
112
_rightEye.backgroundColor = [UIColor blackColor ];
107
- _rightEye.layer .anchorPoint = CGPointMake (1 .7f , 1 .3f );
113
+ _rightEye.layer .anchorPoint = CGPointMake (1 .5f , 1 .5f );
108
114
_rightEye.layer .position = CGPointMake (self.faceView .right - 13 .5f , self.faceView .top + width/3 .0f + 7 .5f );
109
115
[_indicatorView addSubview: _rightEye];
110
116
@@ -230,6 +236,8 @@ - (void)animateWithInteractionEnabled:(BOOL)enabled
230
236
{
231
237
return ;
232
238
}
239
+
240
+ _isAnimating = YES ;
233
241
[_backgroundWindow makeKeyAndVisible ];
234
242
timer = [NSTimer scheduledTimerWithTimeInterval: self .animationDuration * 2 .0f target: self selector: @selector (timerUpdate: ) userInfo: nil repeats: YES ];
235
243
[[NSRunLoop currentRunLoop ] addTimer: timer forMode: NSRunLoopCommonModes ];
@@ -239,15 +247,19 @@ - (void)animateWithInteractionEnabled:(BOOL)enabled
239
247
_backgroundWindow.alpha = 1 .0f ;
240
248
_indicatorView.alpha = 1 .0f ;
241
249
} completion: ^(BOOL finished) {
242
- _isAnimating = YES ;
243
-
244
- [_mouseView.layer addAnimation: [self rotationAnimation ] forKey: @" rotate" ];
245
- [_leftEye.layer addAnimation: [self rotationAnimation ] forKey: @" rotate" ];
246
- [_rightEye.layer addAnimation: [self rotationAnimation ] forKey: @" rotate" ];
247
-
248
- [_leftEyeCover.layer addAnimation: [self scaleAnimation ] forKey: @" scale" ];
249
- [_rightEyeCover.layer addAnimation: [self scaleAnimation ] forKey: @" scale" ];
250
250
}];
251
+
252
+ [_leftEyeCover.layer addAnimation: [self scaleAnimation ] forKey: @" scale" ];
253
+ [_rightEyeCover.layer addAnimation: [self scaleAnimation ] forKey: @" scale" ];
254
+
255
+ [self performSelector: @selector (test ) withObject: nil afterDelay: self .animationDuration * 0 .25f ];
256
+ }
257
+
258
+ - (void )test
259
+ {
260
+ [_mouseView.layer addAnimation: [self rotationAnimation ] forKey: @" rotate" ];
261
+ [_leftEye.layer addAnimation: [self rotationAnimation ] forKey: @" rotate" ];
262
+ [_rightEye.layer addAnimation: [self rotationAnimation ] forKey: @" rotate" ];
251
263
}
252
264
253
265
- (void )animate
@@ -338,15 +350,15 @@ - (CAAnimationGroup *)scaleAnimation
338
350
scaleAnimation = [CABasicAnimation animationWithKeyPath: @" transform" ];
339
351
scaleAnimation.fromValue = [NSValue valueWithCATransform3D: CATransform3DIdentity];
340
352
scaleAnimation.toValue = [NSValue valueWithCATransform3D: CATransform3DMakeScale (1.0 , 3.0 , 1.0 )];
341
- scaleAnimation.duration = self.animationDuration * 0 . 75f ;
353
+ scaleAnimation.duration = self.animationDuration ;
342
354
scaleAnimation.cumulative = YES ;
343
355
scaleAnimation.repeatCount = 1 ;
344
356
scaleAnimation.removedOnCompletion = NO ;
345
357
scaleAnimation.fillMode =kCAFillModeForwards ;
346
358
scaleAnimation.autoreverses = NO ;
347
359
scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints: 0.2 :0.0 :0.8 :1.0 ];
348
360
scaleAnimation.speed = 1 .0f ;
349
- scaleAnimation.beginTime = self. animationDuration * 0 . 25f ;
361
+ scaleAnimation.beginTime = 0 . 0f ;
350
362
351
363
352
364
CAAnimationGroup *group = [CAAnimationGroup animation ];
@@ -355,7 +367,7 @@ - (CAAnimationGroup *)scaleAnimation
355
367
group.removedOnCompletion = NO ;
356
368
group.fillMode =kCAFillModeForwards ;
357
369
group.autoreverses = YES ;
358
- group.timingFunction = [CAMediaTimingFunction functionWithControlPoints: 0.2 :0.0 :0.8 :1.0 ];
370
+ group.timingFunction = [CAMediaTimingFunction functionWithControlPoints: 0.2 :0.0 :0.8 :1.0 ];
359
371
360
372
group.animations = [NSArray arrayWithObjects: scaleAnimation, nil ];
361
373
return group;
0 commit comments