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  
  • 相关阅读:
    [leetCode]剑指 Offer 62. 圆圈中最后剩下的数字
    [leetCode]剑指 Offer 61. 扑克牌中的顺子
    [leetCode]剑指 Offer 60. n个骰子的点数
    POJ
    POJ
    POJ
    codeforces
    LightOJ
    CodeForces
    CodeForces
  • 原文地址:https://www.cnblogs.com/rglmuselily/p/6385190.html
Copyright © 2011-2022 走看看