1

そのフレームUIViewの左下に があります。superview

[myView setFrame:CGRectMake(0,superView.bounds.size.height-myViewHeight,myViewWidth,myViewHeight)];

左下のポイントがその位置に固定されたままになるように、そのサイズをアニメーション化したいと思います。レイヤーのアンカーポイントプロパティで遊ぶ方法がわかりません。現在、次のコード行を使用してサイズを大きくしています。

[UIView animateWithDuration:0.2 animations:^{


            [bottomLbl setFrame:CGRectMake(0, bottomView.bounds.size.height-250, 300, 250)];

これは問題なく動作しますが、元のサイズに戻そうとすると、アニメーションの開始時に下点が持ち上げられ、アニメーションの終了時に落ち着きます。

4

1 に答える 1

0

最初に左下隅のポイントを定義します...

CGPoint bottomLeft = CGPointMake(0, 480); // this can be anything.

次に、サイズ (大小) を定義する必要があります。

CGSize bigSize = CGSizeMake(280, 280);
CGSize smallSize = CGSizeMake(50, 50); // again, these can be anything.

次に、それらをアニメーション化します...

// create the rect for the frame
CGRect bigFrame = CGRectMake(bottomLeft.x, bottomLeft.y - bigSize.height, bigSize.width, bigSize.height);
CGRect smallFrame = CGRectMake(bottomLeft.x, bottomLeft.y - smallSize.height, smallSize.width, smallSize.height);

[UIView animateWithDuration:0.2
                 animations:^{
    // set the rect onto the view
    bottomLbl.frame = bigFrame;
    // or
    bottomLbl.frame = smallFrame;
}];

フレームを設定し、計算された終了フレームが正しく、すべてが 1 つのアニメーションで完了している限り、左下隅は移動しません。

これで問題が解決しない場合は、何が起こっているか (およびすべてのアニメーション コード) のビデオを投稿してください。

編集

[UIView animateWithDuration:0.2
                      delay:0.0
                    options:UIViewAnimationOptionBeginFromCurrentState
                 animations:^{
    // set the rect onto the view
    bottomLbl.frame = bigFrame;
    // or
    bottomLbl.frame = smallFrame;
    }
                 completion:nil];
于 2013-07-08T09:02:12.303 に答える