• 图片的抖动


    Main.storyboard

    ViewControlller.m

    //

    //  ViewController.m

    //  8A03.图片的抖动

    //

    //  Created by huan on 16/2/4.

    //  Copyright © 2016 huanxi. All rights reserved.

    //

     

    #import "ViewController.h"

     

    @interface ViewController ()

    @property (weak, nonatomic) IBOutlet UIImageView *imageView;

     

    @end

     

    @implementation ViewController

     

    - (void)viewDidLoad {

        [super viewDidLoad];

        // Do any additional setup after loading the view, typically from a nib.

    }

     

    -(IBAction)start{

        //抖动图片 使用帧动画 设置 旋转的 路径

        CAKeyframeAnimation *rotationAni = [CAKeyframeAnimation animation];

        rotationAni.keyPath = @"transform.rotation";

        //计算好旋转的弧度

        CGFloat angle = M_PI_4 * 0.3;

        //设置 旋转的路径 (状态)

        

        rotationAni.values = @[@(-angle),@(angle), @(-angle)];

        //设置动画执行的次数

        rotationAni.repeatCount = MAXFLOAT;

        [self.imageView.layer addAnimation:rotationAni forKey:@"shake"];

        

    }

     

    -(IBAction)stop{

        //通过key把动画移除

        [self.imageView.layer removeAnimationForKey:@"shake"];

    }

    @end

    结果

  • 相关阅读:
    HRBUST 1819 石子合并问题--圆形版
    Linux 用户信息英文解释
    day 09 Linux下常见的打包压缩命令
    day 09作业
    第8天作业
    day 08 重定向/管道/sort/uniq/awk详解
    什么是输出重定向
    day07 Linux文件类型及软链接
    第6,7天作业
    day06 Linux根目录下重要目录
  • 原文地址:https://www.cnblogs.com/Lu2015-10-03/p/5191328.html
Copyright © 2020-2023  润新知