TTZoomTransition
是一个自定义模态视图控制器转换,它通过缩放动画显示所呈现的视图控制器。
您可以通过 CocoaPods 使用 TTZoomTransition
。将以下行添加到您的 Podfile
pod TTZoomTransition
将您的模态视图控制器的 modalPresentationStyle
属性设置为 UIModalPresentationCustom
。同时设置 transitioningDelegate
属性。
ModalViewController* modalVC = [[ModalViewController alloc] init];
modalVC.modalPresentationStyle = UIModalPresentationCustom;
modalVC.transitioningDelegate = self;
[self presentViewController:modalVC animated:YES completion:nil];
在您的转换代理中实现 UIViewControllerTransitioningDelegate
的以下方法
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
TTZoomTranstition* zoomTransition = [[TTZoomTranstition alloc] init];
return zoomTransition;
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
TTZoomTranstition* zoomTransition = [[TTZoomTranstition alloc] init];
zoomTransition.presenting = NO;
return zoomTransition;
}
pod try TTZoomTransition
如果您机器上没有 CocoaPods,请安装它:[sudo] gem install cocoapods
。
Tamás Tímár
TTZoomTransition
在 MIT 许可证 之下可用。查看 LICENSE 文件以获取更多信息。
示例中的图片来自 Pixabay。