5

私は非常に単純なタスクに困惑しています.UIViewアニメーションでイーズイン/イーズアウトを行いたいのですが、正しいanimationOptionを使用しているにもかかわらず、常に線形です。

すべてのアカウントで機能するはずのコードを次に示します。これは UIViewControllerAnimatedTransitioning クラスに設定されていますが、以前のカスタム セグエ クラスでも同じ問題が発生しています。

[UIView animateWithDuration:0.4f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^(void) {

        self.dimView.alpha = 1.0;
        self.imageView.frame = self.destinationRect;

    } completion:^(BOOL finished) {

        [self.imageView removeFromSuperview];
        [self.dimView removeFromSuperview];

        [transitionContext completeTransition:YES];

     }];

ただし、次のコードを使用した春のアニメーションは機能しますが、これはやりたくありません。

[UIView animateWithDuration:0.8f delay:0 usingSpringWithDamping:0.7f initialSpringVelocity:2.0f options:UIViewAnimationOptionCurveEaseInOut animations:^(void) {

        self.dimView.alpha = 1.0;
        self.imageView.frame = self.destinationRect;

     } completion:^(BOOL finished){

        [self.imageView removeFromSuperview];
        [self.dimView removeFromSuperview];

        [transitionContext completeTransition:YES];

     }];

シミュレーターと iPad2 テスト デバイスで同じ動作が得られます。私は何か間違ったことをしていますか?フレームまたはアルファ値のアニメーション化に問題はありますか?

4

3 に答える 3

3

代わりにこれを試すことができます.-

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.4f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop)];

self.dimView.alpha = 1.0;
self.imageView.frame = self.destinationRect;

[UIView commitAnimations];

- (void) animationDidStop {
    [self.imageView removeFromSuperview];
    [self.dimView removeFromSuperview];
    [transitionContext completeTransition:YES];
}

それが役に立てば幸い。

于 2013-10-02T11:08:02.460 に答える
1

デフォルトのアニメーション カーブ オプションはUIViewAnimationOptionCurveEaseInOutであるため、これを指定する必要はありません。それはUIViewAnimationOptionCurveLinearあなたが明確にしなければならないということです。

アニメーション カーブが線形であると確信していますか? アニメーションの長さを数秒に設定して、2 つのビューを並べてアニメーション化してみてください。

于 2013-10-08T13:56:52.900 に答える
1

以下を使用できます。

[自己遷移:左]; //必要に応じて呼び出す

enum animationFrom {
    top,
    bottom,
    left,
    right
};

- (void)transition:(NSUInteger)index {
    CATransition *tr=[CATransition  animation];
    tr.duration=0.45;
    tr.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    tr.type=kCATransitionPush;
    tr.delegate=self;
    switch (index) {
        case top:
            tr.subtype=kCATransitionFromBottom;
            break;
        case bottom:
            tr.subtype=kCATransitionFromTop;
            break;
        case left:
            tr.subtype=kCATransitionFromRight;
            break;
        case right:
            tr.subtype=kCATransitionFromLeft;
            break;
        default:
            break;
    }
    [self.view.layer addAnimation:tr forKey:nil];
}
于 2013-10-08T11:45:12.283 に答える