0

CGRect オフスクリーン内で UIImageView を作成することは可能ですか?

ユーザーが UIButton を押した後、画面上でアニメーション化します。

私はこの関数を知っていますCGRectMake(x,y,height, width)が、明らかに x と y は負の値を持つことはできません。

誰でも私を助けることができますか?

4

1 に答える 1

0

はい、可能です。あなたができることがいくつかあります。どこからアニメーション化するかに応じて、イメージビューの x と y を負または<parentView>.bounds.size.width高さなどに設定します。その後、UIView を使用して変更をアニメーション化できます。

したがって、viewDidAppear または任意のメソッドで、アップルのドキュメントから使用できるアニメーションをトリガーします。

+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

すべてのアニメーションを処理します。例を次に示します。

[UIView animateWithDuration:<timeInSecondsOfHowLongItShouldTake>
            animations:^
            {
                    imageView.frame = <CGRectFrameOfPlaceThatYouWantItToGo>
                    //you could also make it fade in with imageView.alpha = 1;
                    //assuming you started out with an alpha < 1
            }
            completion:^(BOOL finished)
            {
                    //do something after it finishes moving 
                    //the imageview into place
            }
];
于 2013-06-20T18:17:33.477 に答える