3

我有一个自定义的 segue,试图复制 pre iOS 7 风格的 push/pop segues:

viewControllers 动画并排,没有变暗。(真的有那么难吗!)

下面的代码有效,除了:

  • 退出页面变暗
  • 进入页面在进入时是黑暗的(随着它移动到位置逐渐变得正常)

这些图像说明了问题:

在此处输入图像描述接着... 在此处输入图像描述

有没有办法阻止这种变暗效果?我会非常感谢一些帮助。

-(void)perform
{
    UIViewController *source = self.sourceViewController;
    UIWindow *window = source.view.window;

    CATransition *transition = [CATransition animation];
    [transition setDuration:2.0];
    [transition setDelegate:self];
    [transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
    [transition setType:@"push"];
    [transition setSubtype:kCATransitionFromRight];

    [window.layer addAnimation:transition forKey:kCATransition];
    [window setRootViewController:self.destinationViewController];
}
4

1 回答 1

1

这两个函数对我来说很好用,虽然代码和你的很相似,但我希望它有所帮助。

+(void) modalRight:(UIViewController*)vc destvc:(UIViewController*)viewCtrl{
    CATransition *transition = [CATransition animation];
    transition.duration = 0.3;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromRight;
    [vc.view.window.layer addAnimation:transition forKey:nil];
    [vc presentModalViewController:viewCtrl animated:NO];
}

+(void) modalLeft:(UIViewController*)vc{
    CATransition *transition = [CATransition animation];
    transition.duration = 0.3;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromLeft;
    [vc.view.window.layer addAnimation:transition forKey:nil];
    [vc dismissModalViewControllerAnimated:NO];
}
于 2013-09-30T12:27:17.633 回答