zoukankan      html  css  js  c++  java
  • 核心动画

    一、瑕疵抖动效果

    这种抖动的幅度很大。

        CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
        
        anim.keyPath = @"transform.rotation";
        
        // 1. 抖動幅度
        anim.values = @[@(angle2Radion(-5)),@(angle2Radion(5))];
        
        // 2. 一直抖動
        anim.repeatCount = MAXFLOAT;
        
        [_imageV.layer addAnimation:anim forKey:nil];

    二、 正常抖动

    只需要 把下方这句代码 改一下就OK

        // 把这句代码改成 
        anim.values = @[@(angle2Radion(-5)),@(angle2Radion(5))];
    
        // 改成这句代码
        anim.values = @[@(angle2Radion(-5)),@(angle2Radion(5)),@(angle2Radion(-5))];

    三、把抖动效果的原点由图片的中心点改成 左上角

     _imageV.layer.anchorPoint = CGPointZero;

    四、摆动

    - (void)viewDidLoad {
        [super viewDidLoad];
        
        _imageV.layer.anchorPoint = CGPointZero;
    }
    // 抖动效果
    - (void)DouDongXiaoGuo
    {
        CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
        
        anim.keyPath = @"transform.rotation";
        
        // 1. 抖動幅度还可以使用path
        anim.path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 5, 5)].CGPath;
        
        anim.duration = 1;
        // 2. 一直抖動
        anim.repeatCount = MAXFLOAT;
        
        [_imageV.layer addAnimation:anim forKey:nil];
    }

    五、position 的画圆

       CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
        
        anim.keyPath = @"position";
        
        // 1. 抖動幅度还可以使用path
        anim.path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(50, 50, 100, 100)].CGPath;
        
        anim.duration = 1;
        // 2. 一直抖動
        anim.repeatCount = MAXFLOAT;
        
        [_imageV.layer addAnimation:anim forKey:nil];

    六、跟随用户所画的线条移动位置

    1. 在SB中拖动一个UIView .

    2. class : WYGrayBgView 类.

    3. 在ViewController中不写任何代码。

    @interface WYGrayBgView ()
    @property (nonatomic,strong) UIBezierPath   *path;
    @end
    
    @implementation WYGrayBgView
    - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch = [touches anyObject];
        
        // 获取手指的触摸点
        CGPoint curP = [touch locationInView:self];
        
        // 创建路径
        UIBezierPath *path = [UIBezierPath bezierPath];
        _path = path;
        
        //设置起点
        [path moveToPoint:curP];
    }
    
    - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch = [touches anyObject];
        
        //获取手指的触摸点
        CGPoint curP = [touch locationInView:self];
        
        [_path addLineToPoint:curP];
        
        [self setNeedsDisplay];
    }
    
    - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    {
        //给imageView 添加核心动画
        CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
        anim.keyPath = @"position";
        
        anim.path = _path.CGPath;
        
        anim.duration = 1;
        
        anim.repeatCount = MAXFLOAT;
        
        [[[self.subviews firstObject] layer] addAnimation:anim forKey:nil];
    }
    
    - (void)drawRect:(CGRect)rect
    {
        [_path stroke];
    }

  • 相关阅读:
    arm linux kernel 从入口到start_kernel 的代码分析
    Booting ARM Linux
    GNU风格 ARM汇编语法指南
    基于linux2.6.38.8内核启动过程完全解析[一]
    基于linux2.6.38.8内核zImage文件的自解压详解
    Busybox支持中文的解决办法
    对Kernel panic-not syncing:No init found...init=option to kernel错误总结!
    Linux 的启动流程
    计算机是如何启动的?
    Debian的定时执行命令Crontab
  • 原文地址:https://www.cnblogs.com/iOS363536404/p/5431017.html
Copyright © 2011-2022 走看看