流行过渡效果自定义故事板Segue

时间:2015-05-05 13:25:20

标签: ios objective-c storyboard segue uistoryboard

使用自定义segue时,如何获得弹出过渡效果?

以下问题几乎完全符合我的要求,但我需要做一个“上一个”/“下一个”类型的动画。

Instead of push segue how to replace view controller (or remove from navigation stack)?

所以,我试图为我们使用CATransition工作。它没有给出正确的效果。

- (void)perform {

    UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];

    // Not quite what I want.
    // will make configurable (pop / push)
    CATransition *transition = [CATransition animation];
    transition.duration = 0.5;
    transition.type = kCATransitionReveal;

    [[[[sourceViewController view] window] layer] addAnimation:transition
                                                               forKey:kCATransitionReveal];


    // Grab Variables for readability
    UIViewController *destinationController = (UIViewController*)[self destinationViewController];
    UINavigationController *navigationController = sourceViewController.navigationController;

    // Get a changeable copy of the stack
    NSMutableArray *controllerStack = [NSMutableArray arrayWithArray:navigationController.viewControllers];
    // Replace the source controller with the destination controller, wherever the source may be
    [controllerStack replaceObjectAtIndex:[controllerStack indexOfObject:sourceViewController] withObject:destinationController];

    // Assign the updated stack with animation
    [navigationController setViewControllers:controllerStack animated:YES];
}

0 个答案:

没有答案
相关问题