左右摇摆

来源:互联网 发布:淘宝成功营销案例 编辑:程序博客网 时间:2024/05/12 15:15

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

    CGFloat rotation = 0.03;

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

    shake.duration = 0.13;

    shake.autoreverses = YES;

    shake.repeatCount = MAXFLOAT;

    shake.removedOnCompletion =NO;

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

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

    [self.layeraddAnimation:shake forKey:@"shakeAnimation"];


停止

    [self.layerremoveAnimationForKey:@"shakeAnimation"];


0 0
原创粉丝点击