SuspensionEntrance仿微信新版懸浮窗入口
SuspensionEntrance 是一個(gè)仿微信新版浮窗入口功能。
使用方法
pod SuspensionExtrance ~> 0.1.0 // 使用podfile方式引入
@implementation BaseNavigationController
- (void)viewDidLoad {
[super viewDidLoad];
// 在自定義的navigationController中 設(shè)置代理, 如果已經(jīng)使用了代理,
self.delegate = [SuspensionEntrance shared];
// 關(guān)閉系統(tǒng)返回手勢
self.interactivePopGestureRecognizer.enabled = NO;
}
@end
// 對于可以作為入口界面的Controller,實(shí)現(xiàn)SEItem協(xié)議
@interface EntranceViewController : UIViewController <SEItem>
@property (copy , nonatomic) NSString *entranceTitle;
@property (copy , nonatomic, nullable) NSURL *entranceIconUrl;
@property (copy , nonatomic, nullable) NSDictionary *entranceUserInfo;
@end
// 并實(shí)現(xiàn)下列構(gòu)造方法, !!! 如果不實(shí)現(xiàn)則無法進(jìn)行序列化存儲
+ (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;
}
一般情況下, 我們自己項(xiàng)目內(nèi)都會(huì)使用自定義返回手勢, 并且已經(jīng)設(shè)置了代理, 那可以采用下列的方式進(jìn)行對接
// 在對應(yīng)的代理方法里面調(diào)用
- (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];
}
// 然后同上面一步, 一樣實(shí)現(xiàn)SEItem協(xié)議, 需要注意的事, 需要手動(dòng)關(guān)閉自定義返回手勢, 以避免手勢沖突
// 以集成了 forkingdog/FDFullscreenPopGesture(https://github.com/forkingdog/FDFullscreenPopGesture) 為例, 添加下列方法
- (void)fd_interactivePopDisabled { return YES; }
評論
圖片
表情
