我创建了两个自定义 segue 文件,并且在这两个文件中,我都覆盖了该perform
方法。但是,似乎自定义 segue 仅在呈现 new 时才有效UIViewController
,而相反的 segue 不设置动画,只是忽略了 source UIViewController
。
反向自定义segue:
- (void)perform {
UIViewController *sourceViewController = self.sourceViewController;
UIViewController *sourceTabBarController = sourceViewController.parentViewController.parentViewController;
UIViewController *destinationViewController = self.destinationViewController;
UIGraphicsBeginImageContext(destinationViewController.view.bounds.size);
[destinationViewController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *destinationViewControllerImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *destinationViewControllerImageView = [[UIImageView alloc] initWithImage:destinationViewControllerImage];
destinationViewControllerImageView.userInteractionEnabled = YES;
destinationViewControllerImageView.frame = CGRectMake(0.0f, 0.0f, CGRectGetWidth(destinationViewController.view.frame), CGRectGetHeight(destinationViewController.view.frame));
[destinationViewController.view insertSubview:destinationViewControllerImageView atIndex:1];
// Add animations
[UIView animateWithDuration:0.4f
delay:0.0f
options:UIViewAnimationOptionCurveEaseIn
animations:^{
destinationViewControllerImageView.center = CGPointMake(-CGRectGetWidth(destinationViewControllerImageView.frame) / 2, -(CGRectGetHeight(destinationViewControllerImageView.frame) / 2));
}
completion:nil];
[sourceViewController dismissViewControllerAnimated:NO completion:nil];
}
提前致谢!