0

我有以下代码

UIImageView *r = [[UIImageView alloc] initWithFrame:CGRectMake(10, 80, 300, 300)];
r.image = [UIImage imageNamed:@"testbg"];

[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:0.1];
r.transform = CGAffineTransformMakeRotation(deg(30));
[UIImageView commitAnimations];

r.image = [UIImage imageNamed:@"rotbg"];

o 旋转后,我想更改视图中的图像,但它会被旋转,如何在不旋转的情况下绘制图像?

4

2 回答 2

1

不确定我是否正确理解了您的问题,但我认为您可以执行以下操作:

UIImageView *r = [[UIImageView alloc] initWithFrame:CGRectMake(10, 80, 300, 300)];
r.image = [UIImage imageNamed:@"testbg"];

[UIView animateWithDuration:0.1
                 animations:^(){
                     r.transform = CGAffineTransformMakeRotation(deg(30));
}
                 completion:^(BOOL finished){
                     r.transform = CGAffineTransformMakeRotation(0);
                     r.image = [UIImage imageNamed:@"rotbg"];
}];
于 2013-02-26T16:15:11.613 回答
1

好吧,我想这就是你想要的......

UIImageView *r = [[UIImageView alloc] initWithFrame:CGRectMake(10, 80, 300, 300)];
r.image = [UIImage imageNamed:@"testbg"];

[UIView animateWithDuration:0.1
 delay:0.0 options:UIViewAnimationOptionCurveEaseIn
 animations:^{
     r.transform = CGAffineTransformMakeRotation(deg(30));
 }

 completion:^(BOOL finished){
           if(finished){
             r.transform = CGAffineTransformMakeRotation(0);
             r.image = [UIImage imageNamed:@"rotbg"];
           }

}];
于 2013-02-26T16:19:21.363 回答