2016-09-07 25 views
-2

我需要現在的模態視圖控制器從左到右動畫,如 抽屜?我需要現在的模態視圖控制器從左到右像抽屜一樣動畫

我的代碼: -

MenuViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MenuViewStory"]; 
vc.delegate= self; 
CATransition *transition = [CATransition animation]; 
transition.duration = 0.6; 
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
transition.type = kCATransitionMoveIn; 
transition.subtype = kCATransitionFromLeft; 
[vc.view.window.layer addAnimation:transition forKey:nil]; 
[self presentViewController:vc animated:YES completion:nil]; 
+0

與我們分享你試過請 –

+0

MenuViewController * VC = [self.storyboard instantiateViewControllerWithIdentifier:@「MenuViewStory」]; vc.delegate = self; CATransition * transition = [CATransition animation]; transition.duration = 0.6; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionMoveIn; transition.subtype = kCATransitionFromLeft; [vc.view.window.layer addAnimation:transition forKey:nil]; [self presentViewController:vc animated:YES completion:nil]; – Abhimanyu

+0

請編輯問題並在其中添加代碼,而不是在評論中 –

回答

0

嘿,你可以使用下面的方法,而在導航控制器推控制器動畫NO

- (void)animateControllerFromLeftToRight 
{ 
    CATransition *animation = [CATransition animation]; 
    [animation setDelegate:self]; 
    [animation setType:kCATransitionPush]; 
    [animation setSubtype:kCATransitionFromRight]; 
    [animation setDuration:0.65f]; 
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 
    [[self.navigationController.view layer] addAnimation:animation forKey:@"AnimationFromLeftToRight"]; 
} 
相關問題