到目前为止我的代码是为的UIImageView旋转动画旋转别的
rotateButton = [UIButton new];
rotateButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[rotateButton setFrame:CGRectMake(334, 80, 100, 20)];
[rotateButton addTarget:self action:@selector(rotateImageView:Degrees:InTimePeriod:) forControlEvents:UIControlEventTouchUpInside];
[rotateButton setTitle:@"Rotate" forState:UIControlStateNormal];
[self.view addSubview:rotateButton];
-(void)rotateImageView
{
[self rotateImageView:imageView Degrees:90 InTimePeriod:1.5];
}
-(void)rotateImageView:(UIImageView*)imageView Degrees:(NSInteger)degrees InTimePeriod:(float)time
{
CABasicAnimation *rotate;
rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotate.fromValue = [NSNumber numberWithFloat:0];
rotate.toValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(degrees)];
rotate.duration = time;
rotate.repeatCount = 1;
[imageView.layer addAnimation:rotate forKey:@"Rotate"];
}
但是,我用它来启动旋转按钮后,我按下按钮,而不是ImageView的,我希望它是旋转对象旋转。我该如何使imageView旋转?
当我尝试,我得到了错误SIGABRT – aeubanks 2013-03-07 02:26:11
在这种情况下,你有一个错误的地方。你可能不应该直接访问imageView,而是这样做:[self rotateImageView:self.imageView Degrees:90 InTimePeriod:1.5]; – 2013-03-07 02:29:11