模仿《百度音乐HD》添加到下载框动画

上次听有人说喜欢《百度音乐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

相关文章
相关标签/搜索