33

iPhoneアプリの「ポップイン」に画像を表示するだけでなく、画面に表示したいと思います。「ポップイン」とは、小さなドットから実際のサイズに成長することを意味します. 参考までに、これは Keynote の「ポップ」アニメーション効果とまったく同じです。私は iOS アニメーションにまったく慣れていないので、使用する必要があるアニメーション効果の方向性を誰かが教えてくれれば、非常にありがたいです。

ありがとう

ブライアン

更新 以下の提案からこのコードを追加しました。これは機能しますが、画像を拡大ではなく縮小します。変換スケール サイズが 0.01 であることはわかっていますが、サイズ 0.0 の画像から始めて 1 にスケールアップする方法を知りたいです。画像のサイズを0? ありがとう

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.2];
image.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
4

5 に答える 5

80

あなたが探している効果は次のようなものです:

// instantaneously make the image view small (scaled to 1% of its actual size)
view.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
    // animate it to the identity transform (100% scale)
    view.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished){
    // if you want to do something once the animation finishes, put it here
}];
于 2012-03-30T18:31:01.933 に答える
0

ビューのフレームをアニメーション化して、ゼロから最終状態に縮小する必要があります。これは、たとえば UIView ブロック アニメーションで行うことができます。

したがって、たとえば、最終的なサイズと位置を持つ IBOutlet プロパティ self.myView としてビューから始めますが、隠しフラグを設定します。次に、それを表示したい場合は、次を使用します。

// Save old frame as final stater and set it to zero size for the start of the animation
// But keep the same center position, so it just grows and don't move around 
CGRect oldFrame = self.myView.frame;
CGRect oldCenter = self.myView.center;

self.myView.frame = CGRectZero;
self.myView.center = oldCenter;

self.myView.hidden = NO;

NSTimeInterval duration = 0.3;

[UIView animateWithDuration:duration delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
                // New position and size after the animation should be the same as in Interface Builder
                self.myView.frame = oldFrame
    }
                     completion:^(BOOL finished){
                                                 // You can do some stuff here after the animation finished
                     }];
于 2012-03-30T17:42:36.377 に答える