zoukankan      html  css  js  c++  java
  • iOS之UITextField输入错误的震动动画

     1 //左右震动效果
     2 - (void)shake:(UIView *)view {
     3 CGRect frame = view.frame;
     4 CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
     5 
     6 CGMutablePathRef shakePath = CGPathCreateMutable();
     7 CGPathMoveToPoint(shakePath, NULL, frame.origin.x+frame.size.width/2, frame.origin.y+frame.size.height/2);
     8 int index;
     9 for (index = 3; index >=0; --index) {
    10 CGPathAddLineToPoint(shakePath, NULL, frame.origin.x+frame.size.width/2 - frame.size.width * 0.02f * index, frame.origin.y+frame.size.height/2);
    11 CGPathAddLineToPoint(shakePath, NULL, frame.origin.x+frame.size.width/2 + frame.size.width * 0.02f * index, frame.origin.y+frame.size.height/2);
    12 }
    13 CGPathCloseSubpath(shakePath);
    14 
    15 shakeAnimation.path = shakePath;
    16 shakeAnimation.duration = 0.5f;
    17 shakeAnimation.removedOnCompletion = YES;
    18 
    19 [view.layer addAnimation:shakeAnimation forKey:nil];
    20 CFRelease(shakePath);
    21 }
    22 
    23  
  • 相关阅读:
    E
    D
    C
    B
    Python
    IDEA 设置资源目录
    光猫指示灯含义
    IO模型
    Linux 总目录
    Linux python 使用
  • 原文地址:https://www.cnblogs.com/rglmuselily/p/6385190.html
Copyright © 2011-2022 走看看