【技术】左右晃动

左右摇摆   //self 就是摇摆的view

    CGFloat rotation = 0.03;

    CABasicAnimation *shake = [CABasicAnimation animationWithKeyPath:@"transform"];

    shake.duration = 0.13;

    shake.autoreverses = YES;

    shake.repeatCount = MAXFLOAT;

    shake.removedOnCompletion = NO;

    shake.fromValue = [NSValue valueWithCATransform3D:CATransform3DRotate(self.layer.transform,-rotation,0.0 ,0.0 ,1.0)];

    shake.toValue   = [NSValue valueWithCATransform3D:CATransform3DRotate(self.layer.transform, rotation,0.0 ,0.0 ,1.0)];

    [self.layer addAnimation:shake forKey:@"shakeAnimation"];


停止

    [self.layer removeAnimationForKey:@"shakeAnimation"];

你可能感兴趣的:(transform,左右,shakeAnimation)