旋转imageView,同时移动它

所以我有一个名为图像的UIView ,我试图让它旋转,而我上下移动视图,这是我迄今为止所做的,但它使图片旋转,而不是下降:

 { return centerY - height / 2 <= 10 || centerY + height/ 2 >= self.view.bounds.size.height - 10; } -(void)moveUpDownTimerCallback { [UIView commitAnimations]; verticalSpeed += acceleration; degrees+=degreechange; CGSize sz = image.bounds.size; image.transform = CGAffineTransformMakeRotation(degrees * M_PI/180),image.layer.anchorPoint = CGPointMake(rotPointx/sz.width,rotPointy/sz.height);rotPointy = image.center.y; rotPointx = image.center.x; CGPoint newCenter = CGPointMake(image.center.x, image.center.y + verticalSpeed); if ([self hasCollided: image.center.y + verticalSpeed imageHeight: image.bounds.size.height]) { acceleration = 0; [self moveUpDown: 0]; } else { image.center = newCenter; } } -(void)moveUpDown:(int) vSpeed { verticalSpeed = vSpeed; if (verticalSpeed != 0 || acceleration != 0) { if (timer == nil) timer =[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(moveUpDownTimerCallback) userInfo:nil repeats:YES]; } } else { if (timer != nil) { [timer invalidate]; timer = nil; } } } 

任何帮助将非常感激 (:

尝试使用此方法旋转imageview

  CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.fromValue = @0.0f; animation.toValue = @(2*M_PI); animation.duration = 1.0f; // this might be too fast animation.repeatCount = HUGE_VALF; // HUGE_VALF is defined in math.h so import it [self.imageview1.layer addAnimation:animation forKey:@"rotation"]; 

并用这种方法移动视图

 CGRect frameBottomview1 = self.yourview.frame; frameBottomview1.origin.y = 300; [UIView animateWithDuration:0.7 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ [self.yourview setFrame:frameBottomview1 ]; } completion:nil]; 

在这里输入图像说明

你正在采取完全错误的做法。 你应该使用新的基于块的UIViewanimation方法,如animateWithDuration:animations:它是堂兄弟。

您可以同时animation旋转和移动。

如果你可以限制你的开发到iOS 7,那么有一些新的基于关键帧的animation方法可以让你很容易地做一个定时的animation序列。