Ich habe untersucht, wie Animationen zu UIAlertView
's Schicht hinzugefügt werden, indem Sie -[CALayer addAnimation:forKey:]
swizzlen. Hier sind die Werte, die ich für die Skala bekam verwandeln Animationen es führt:
0.01f -> 1.10f -> 0.90f -> 1.00f
mit Dauern
0.2s, 0.1s, 0.1s
.
Alle Animationen verwenden eine einfache Ein-/Ausstiegsfunktion. Hier ist eine CAKeyframeAnimation
, die diese Logik kapselt:
CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
bounceAnimation.fillMode = kCAFillModeBoth;
bounceAnimation.removedOnCompletion = YES;
bounceAnimation.duration = 0.4;
bounceAnimation.values = @[
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.01f, 0.01f, 0.01f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1f, 1.1f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9f, 0.9f)],
[NSValue valueWithCATransform3D:CATransform3DIdentity]];
bounceAnimation.keyTimes = @[@0.0f, @0.5f, @0.75f, @1.0f];
bounceAnimation.timingFunctions = @[
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
Ich glaube UIAlertView
auch eine einfache Opazität Animation 0.0f
-1.0f
über die gesamte Dauer der Animation verwandeln führt (0.4
).
Vielen Dank! Das war sehr hilfreich. –