我有一个 ViewController 可以说ViewControllerA
和一个 ViewController 可以说ViewControllerB
。
ViewControllerB
ViewControllerA
通过使用自定义转换以模态方式呈现。
在 ViewControllerA 中:
-(void)buttonClicked...
{
ViewControllerB * controller = [[ViewControllerB alloc] init];
[controller setModalPresentationStyle:UIModalPresentationCustom];
controller.transitioningDelegate = self;
[self presentViewController:controller animated:YES completion:nil];
}
在 ViewControllerA -
#pragma mark - UIViewControllerTransitioningDelegate
-
(id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
presentingController:(UIViewController *)presenting
sourceController:(UIViewController *)source
{
FadeInWithPopAnimator* fadeInAnimator = [[FadeInWithPopAnimator alloc] init];
return fadeInAnimator;
}
我有一个名为的自定义 Animator 类FadeInWithPopAnimator
,它实现了 transitionDuration 和 animationTransition 方法。
我想在呈现的 viewcontroller - 上为几个视图设置动画ViewControllerB
,在过渡动画开始后 0.2 秒。
我已经在线阅读了文档,看起来使用 transitionCoordinator 是要走的路。但是我应该把代码放在哪里?
1) 在调用 presentViewController 时ViewControllerA
?
2)在动画师类?
3) 在视图中会出现ViewControllerA
什么?
我已经尝试了几件事,但它没有给我结果,而且很难找到例子。