让图片360度旋转,M_PI 是 π 的宏定义,3.1415926
UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(-40, 350, 400, 400)]; [iv setImage:[UIImage imageNamed:@"7"]]; //CALayer *rotate_layer = iv.layer; [self.view addSubview:iv]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; animation.delegate = self; animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI , 0, 0, 1.0)]; animation.duration = 30; animation.cumulative = YES; animation.repeatCount = INT_MAX; [iv.layer addAnimation:animation forKey:@"animation"];