File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ typedef enum {
83
83
@property (nonatomic , assign ) CGSize progressViewSize;
84
84
/* *The origin of the show/hide animation. show: will animate from this point, and hide: will animate to this point.*/
85
85
@property (nonatomic , assign ) CGPoint animationPoint;
86
+ /* *If true, animation doesn't come from animation point, but frame background view position
87
+ */
88
+ @property (nonatomic , assign ) BOOL animationCentered;
86
89
87
90
/* *@name Properties*/
88
91
/* *The durations of animations in seconds.*/
Original file line number Diff line number Diff line change @@ -320,7 +320,16 @@ - (void)show:(BOOL)animated
320
320
321
321
CABasicAnimation *positionAnimation = [CABasicAnimation animationWithKeyPath: @" position" ];
322
322
positionAnimation.duration = _animationDuration;
323
- positionAnimation.fromValue = [NSValue valueWithCGPoint: _animationPoint];
323
+
324
+ if (_animationCentered)
325
+ {
326
+ positionAnimation.fromValue = [NSValue valueWithCGPoint: backgroundView.layer.position];
327
+ }
328
+ else
329
+ {
330
+ positionAnimation.fromValue = [NSValue valueWithCGPoint: _animationPoint];
331
+ }
332
+
324
333
positionAnimation.toValue = [NSValue valueWithCGPoint: backgroundView.layer.position];
325
334
positionAnimation.removedOnCompletion = YES ;
326
335
@@ -351,9 +360,22 @@ - (void)hide:(BOOL)animated
351
360
scaleAnimation.removedOnCompletion = YES ;
352
361
353
362
CABasicAnimation *frameAnimation = [CABasicAnimation animationWithKeyPath: @" position" ];
354
- frameAnimation.fromValue = [NSValue valueWithCGPoint: backgroundView.layer.position];
355
- frameAnimation.toValue = [NSValue valueWithCGPoint: _animationPoint];
363
+
364
+ if (_animationCentered)
365
+ {
366
+ frameAnimation.toValue = [NSValue valueWithCGPoint: backgroundView.layer.position];
367
+ }
368
+ else
369
+ {
370
+ frameAnimation.toValue = [NSValue valueWithCGPoint: _animationPoint];
371
+ }
372
+
356
373
frameAnimation.removedOnCompletion = YES ;
374
+
375
+ if (!_animationCentered)
376
+ {
377
+ backgroundView.layer .position = _animationPoint;
378
+ }
357
379
backgroundView.layer .position = _animationPoint;
358
380
359
381
CAAnimationGroup *animationGroup = [CAAnimationGroup animation ];
You can’t perform that action at this time.
0 commit comments