0
我想在一個視圖控制器在屏幕幻燈片,然後在某個時候滑出並回到呈現的ViewController。 我用這個代碼從我MainViewController啓動模式,然後將其關閉。dismissViewControllerAnimated不是動畫的ViewController
爲什麼解僱滑動動畫不工作?
// Present a React Component sliding from the right on top of current ViewController
+ (void)presentSlidingFromRight:(UIViewController*)presented onViewController:(UIViewController*)presenterVC {
CATransition *transition = [[CATransition alloc] init];
transition.duration = 1;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[presenterVC.view.window.layer addAnimation:transition forKey:kCATransition];
[presenterVC presentViewController:presented animated:NO completion:nil];
}
// Dismiss a React Component sliding to the right
+ (void)dismissSlidingToRight:(UIViewController*)presented onViewController:(UIViewController*)presenterVC {
CATransition *transition = [[CATransition alloc] init];
transition.duration = 3;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[presenterVC.view.window.layer addAnimation:transition forKey:kCATransition];
[presenterVC dismissViewControllerAnimated:NO completion:nil];
}
你的靜態功能,當我把它設置爲YES,模態動畫但是默認的動畫(滑動底部快)。爲什麼忽略我的轉換? – Herno
@赫爾諾在解僱功能,你可以嘗試改變過渡類型,使用淡出而不是推: 'transition.type = kCATransitionFade;' – zero
感謝您的幫助。所以如果我在我的MainView控制器中運行代碼,它運行良好。但是,因爲我有這個靜態類,我不知道它爲什麼不動畫。我保持_presented,並提出控制器在varaibles供以後使用。這是相同的代碼,但是當我在另一個類,是不是MainViewController使用它,它不工作。這有多奇怪? – Herno