且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 iPhone 上的应用程序定期启动时复制放大动画(在主屏幕上推送应用程序图标)

更新时间:2021-08-28 09:11:35

你可以用 CABasicAnimation 和 CAAnimationGroup 做同样的事情,我实际上认为 Core Animation 比 UIKit Animations 更流畅,它给你更多的控制.

You can do the same thing with CABasicAnimation and CAAnimationGroup, I actually thought that Core Animation over UIKit Animations was smoother and It gives you more control.

CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.removedOnCompletion = YES;

CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnimation.fromValue = [NSNumber numberWithFloat:0.0];
fadeAnimation.toValue = [NSNumber numberWithFloat:1.0];

CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation.fromValue = [NSNumber numberWithFloat:0.5];
scaleAnimation.toValue = [NSNumber numberWithFloat:1.00];

animationGroup.animations = [NSArray arrayWithObjects:fadeAnimation, scaleAnimation, nil];

[self.layer addAnimation:animationGroup forKey:@"fadeAnimation"];
self.layer.opacity = 1.0;

给猫剥皮的方法总是不止一种"

"There's always more then one way to skin a cat"