zoukankan      html  css  js  c++  java
  • 模仿《百度音乐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 :




    源代码下载

  • 相关阅读:
    圆的国度:Can you understand what you see?
    P5732 杨辉三角
    Django中与CSRF相关的内容
    Python中一些可能会问到的面试题
    python协程,线程的其他方法
    python 线程
    python-进程-其他方法(2)
    python 进程的一些其他方法
    python进程--传参,for循环创建,join方法
    python并发编程
  • 原文地址:https://www.cnblogs.com/snake-hand/p/3148108.html
Copyright © 2011-2022 走看看