上次聽有人說喜歡《百度音樂HD》添加到下載動畫 ,我就嘗試模仿了下,沒想到,今天code4app(地址)也有了這個,可是 這個動畫基本相同,咱們的思路仍是部同樣的。 均可以參考html
。主要關鍵代碼是:ios
- (void)tranAction:(id)sender { CGPoint fromPoint = self.imageView.center; //路徑曲線 UIBezierPath *movePath = [UIBezierPath bezierPath]; [movePath moveToPoint:fromPoint]; CGPoint toPoint = CGPointMake(20, 570); [movePath addQuadCurveToPoint:toPoint controlPoint:CGPointMake(20,0)]; CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"]; moveAnim.path = movePath.CGPath; moveAnim.removedOnCompletion = YES; //旋轉變化 CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"]; scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity]; //x,y軸縮小到0.1,Z 軸不變 scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.3, 0.3, 1.0)]; scaleAnim.removedOnCompletion = YES; //透明度變化 CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"]; opacityAnim.fromValue = [NSNumber numberWithFloat:1.0]; opacityAnim.toValue = [NSNumber numberWithFloat:0.4]; opacityAnim.removedOnCompletion = YES; //路徑,旋轉,透明度組合起來執行 CAAnimationGroup *animGroup = [CAAnimationGroup animation]; animGroup.animations = [NSArray arrayWithObjects:moveAnim, scaleAnim,opacityAnim, nil]; animGroup.duration = 1; [self.imageView.layer addAnimation:animGroup forKey:nil]; }
效果以下:git
效果土2 :github
源代碼下載
app