zoukankan      html  css  js  c++  java
  • UIView 及其子类对象 抖动效果的实现

    原理:实质就是在UIView的层上加了一个动画并不断的重复
    代码:
        CATransform3D transform;
        if (arc4random() % 2 == 1)//这是为了让不同的View对象向左或向右转动
            transform = CATransform3DMakeRotation(-0.08, 0, 0, 1.0);  (左抖动的幅度,0,0,1.0)
        else
            transform = CATransform3DMakeRotation(0.08, 0, 0, 1.0);  (右抖动的幅度,0,0,1.0)
      
        CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; 
        animation.toValue = [NSValue valueWithCATransform3D:transform]; 
        animation.autoreverses = YES;  
        animation.duration = 0.1;   //间隔时间
        animation.repeatCount = 10000;   //重复的次数
        animation.delegate = self; 
        [[self layer] addAnimation:animation forKey:@"wiggleAnimation"];
  • 相关阅读:
    C/C++分别读取文件的一行
    (转载)C库函数strtok()
    (转载)C++常量折叠和C语言中const常量对比
    ssh
    ubuntu ufw
    uplevel
    ubuntu lucid source.list
    tail
    socket client with proc
    pack forget
  • 原文地址:https://www.cnblogs.com/cnsec/p/11515867.html
Copyright © 2011-2022 走看看