オーディオ ファイルに従って UIImage にアニメーションを作成する必要があります。サウンドが開始したら、特定のポイントにズームしてから、ズームアウトするために同じアニメーションを適用する必要があります。CGAffineTransformMakeScale を適用しようとしましたが、アニメーションが作成されません。画像にズームイン/ズームアウトを適用する正しい方法はどれですか?
1272 次
1 に答える
4
画像をUIImageViewに入れてから、uiviewアニメーションを使用し、フレームを再設定します
例 :
最初に、通常どおりイメージをデプロイします
UIImage *myImg = [UIImage imageNamed:@"myImage.png"];
UIImageView *myImgView = [[UIImageView alloc]initWithImage:myImg];
[myImgView setFrame:CGRectMake(10, 10, 100, 100)];
[self.view addSubview:myImgView];
次に、ビューを大きくするアニメーション コードを実装します。
//START THE ANIMATION
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[myImgView setFrame:CGRectMake(10, 10, 300, 300)]; //re-set your image view size so that it become bigger
[UIView commitAnimations];
または、方法 animate を使用できます(これはもう少し進んでいますが、より良いと思います)
//START THE ANIMATION
[UIView animateWithDuration:1.0 animations:^
{
[myImgView setFrame:CGRectMake(10, 10, 300, 300)]; //re-set your image view size so that it become bigger
} completion:^(BOOL finished)
{
//type here what you want your program to do after the animation finished
}];
頑張ってください:D
于 2012-05-01T07:21:35.087 に答える