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"];

回転後、ビュー内の画像を変更したいのですが、回転します。回転せずに画像を描画するにはどうすればよいですか?

4

2 に答える 2

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 に答える
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 に答える