UIImage * image = [UIImage imageNamed:@"xqx.jpg"]; self.imageView.image = image; CABasicAnimation * shake = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; shake.fromValue = [NSNumber numberWithFloat:-M_PI/45];//45可以修改,越小,摆动的幅度越大 shake.toValue = [NSNumber numberWithFloat:+M_PI/45]; shake.duration = 0.1;//摆动一次耗时 shake.autoreverses = YES; shake.repeatCount = 5;//摆动次数 [self.imageView.layer addAnimation:shake forKey:@"shakeAnimation"]; self.imageView.alpha = 1.0;