SuspensionEntrance 介绍
仿微信新版浮窗入口功能
使用方法
pod SuspensionExtrance ~> 0.1.0 // 使用podfile方式引入 @implementation BaseNavigationController - (void)viewDidLoad { [super viewDidLoad]; // 在自定义的navigationController中 设置代理, 如果已经使用了代理, self.delegate = [SuspensionEntrance shared]; // 关闭系统返回手势 self.interactivePopGestureRecognizer.enabled = NO; } @end // 对于可以作为入口界面的Controller,实现SEItem协议 @interface EntranceViewController : UIViewController <SEItem> @property (copy , nonatomic) Nsstring *entranceTitle; @property (copy , nonatomic, nullable) NSURL *entranceIconUrl; @property (copy , nonatomic, nullable) NSDictionary *entranceUserInfo; @end // 并实现下列构造方法, !!! 如果不实现则无法进行序列化存储 + (instancetype)entranceWithItem:(id<SEItem>)item { EntranceViewController *controller = [[EntranceViewController alloc] initWithNibName:nil bundle:nil]; controller.entranceTitle = item.entranceTitle; controller.entranceIconUrl = item.entranceIconUrl; controller.entranceUserInfo = item.entranceUserInfo; return controller; }
一般情况下, 我们自己项目内都会使用自定义返回手势, 并且已经设置了代理, 那可以采用下列的方式进行对接
// 在对应的代理方法里面调用 - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { [[SuspensionEntrance shared] navigationController:navigationController willShowViewController:viewController animated:animated]; } - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { [[SuspensionEntrance shared] navigationController:navigationController didShowViewController:viewController animated:animated]; } - (id<UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransitioning>)animationController { return [[SuspensionEntrance shared] navigationController:navigationController interactionControllerForAnimationController:animationController]; } - (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC { return [[SuspensionEntrance shared] navigationController:navigationController animationControllerForOperation:operation fromViewController:fromVC toViewController:toVC]; } // 然后同上面一步, 一样实现SEItem协议, 需要注意的事, 需要手动关闭自定义返回手势, 以避免手势冲突 // 以集成了 forkingdog/FDFullscreenPopGesture(https://github.com/forkingdog/FDFullscreenPopGesture) 为例, 添加下列方法 - (void)fd_interactivePopdisabled { return YES; }
SuspensionEntrance 官网
https://github.com/ws00801526/SuspensionEntrance
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。