类似于支付宝手势页面 UILabel抖动效果

/**

 *  UILabel抖动效果

 */

-(void)lockAnimationForView:(UIView*)view

{

    CALayer *lbl = [view layer];

    CGPoint posLbl = [lbl position];

    CGPoint y = CGPointMake(posLbl.x-10, posLbl.y);

    CGPoint x = CGPointMake(posLbl.x+10, posLbl.y);

    CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:@"position"];

    [animation setTimingFunction:[CAMediaTimingFunction

                                  functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [animation setFromValue:[NSValue valueWithCGPoint:x]];

    [animation setToValue:[NSValue valueWithCGPoint:y]];

    [animation setAutoreverses:YES];

    [animation setDuration:0.08];

    [animation setRepeatCount:3];

    [lbl addAnimation:animation forKey:nil];

}

你可能感兴趣的:(类似于支付宝手势页面 UILabel抖动效果)