【技术】左右晃动

来源:互联网 发布:网络热血传奇沙巴克 编辑:程序博客网 时间:2024/05/17 01:39

左右摇摆   //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"];

1 0
原创粉丝点击