背景
在我们的产品中,会遇到产品同学要求展示各种内容的弹窗,比如:
实现及使用方法
我自己模仿系统的弹窗效果,实现了任意UIViewController的弹窗,JFTransition:实现及demo。
在PresentingViewController中,以下面的方式present出弹窗VC
JFPresentedViewController *presentedViewController = [JFPresentedViewController new];
presentedViewController.modalPresentationStyle = UIModalPresentationCustom;
presentedViewController.transitioningDelegate = self.alertModalTransitionDelegate;
[self presentViewController:presentedViewController animated:YES completion:nil];
复制代码
self.alertModalTransitionDelegate就是定义的弹窗效果的delegate, 简单的几句代码就能呈现出弹窗效果。详细用法请见JFTransition。
你可通过 pod JFTransition添加到你的工程里,即可使用。 如果你喜欢JFTransition这个库,请star一下,谢谢。 如果有问题,可以留言,我们互相探讨学习。
参考文章:iOS 视图控制器转场详解