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


    上次听有人说喜欢《百度音乐HD》添加到下载动画 ,我就尝试模仿了下,没想到,今天code4app(地址)也有了这个,但是 这个动画基本相同,我们的思路还是部一样的。 都可以参考

    。主要关键代码是:

    - (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];
        
    }

    效果如下:

    效果土2 :




    源代码下载

  • 相关阅读:
    20160813上午训练记录
    [bzoj 2159]Crash的文明世界
    【娱乐】高端小游戏Manufactoria
    【教程】如何正确的写一个Lemon/Cena的SPJ(special judge)
    [CF]codeforces round#366(div2)滚粗记
    洛谷 [P3265] 装备购买
    POJ 1830 开关问题
    洛谷 [P4035] 球形空间生成器
    BZOJ 2973 入门OJ4798 石头游戏
    洛谷 [P1939] 矩阵加速数列
  • 原文地址:https://www.cnblogs.com/snake-hand/p/3148108.html
Copyright © 2020-2023  润新知