左右晃動(dòng)
```
CALayer*viewLayer=[selflayer];
CGPointposition = viewLayer.position;
CGPointx =CGPointMake(position.x+3, position.y);
CGPointy =CGPointMake(position.x-3, position.y);
CABasicAnimation*animation = [CABasicAnimationanimationWithKeyPath:@"position"];
[animationsetTimingFunction:[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionDefault]];
[animationsetFromValue:[NSValuevalueWithCGPoint:x]];
[animationsetToValue:[NSValuevalueWithCGPoint:y]];
animation.duration=0.2;//持續(xù)時(shí)間
animation.repeatCount=5;//抖動(dòng)次數(shù)
animation.autoreverses=YES;//反極性
[viewLayeraddAnimation:animationforKey:nil];
```
刪除類(lèi)似的晃動(dòng)
```
CALayer*viewLayer=[selflayer];
CABasicAnimation*animation=[CABasicAnimationanimationWithKeyPath:@"transform"];
animation.duration=0.2;//持續(xù)時(shí)間
animation.repeatCount=5;//抖動(dòng)次數(shù)
animation.autoreverses=YES;//反極性
animation.fromValue= [NSValuevalueWithCATransform3D:CATransform3DRotate(viewLayer.transform,-0.08,0.0,0.0,0.08)];
animation.toValue= [NSValuevalueWithCATransform3D:CATransform3DRotate(viewLayer.transform,0.08,0.0,0.0,0.08)];
[viewLayeraddAnimation:animationforKey:@"wiggle"];
```