侧滑抽屉
https://github.com/mutualmobile/MMDrawerController#features
github上的一个开源侧滑框架,拥有自定义侧滑手势功能。但官方的文档只介绍了如何使用。没介绍如何自定义手势。使用MMDrawerController来实现菜单滑动效果。要求是每个一级页面是可以滑动的,二级页面是不允许滑动的。那就需要自定义侧滑手势了。
// 自定义侧滑手势
[_drawerController setGestureShouldRecognizeTouchBlock:^BOOL(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) {
BOOL shouldRecognizeTouch = NO;
if(drawerController.openSide == MMDrawerSideNone &&
[gesture isKindOfClass:[UIPanGestureRecognizer class]]){
UITabBarController *tabVC = (UITabBarController *)drawerController.centerViewController;
if([[(UINavigationController *)[tabVC selectedViewController] topViewController] isKindOfClass:[MainViewController class]] ||
[[(UINavigationController *)[tabVC selectedViewController] topViewController] isKindOfClass:[ShoppingCartViewController class]] ||
[[(UINavigationController *)[tabVC selectedViewController] topViewController] isKindOfClass:[VIPServicesViewController class]] ||
[[(UINavigationController *)[tabVC selectedViewController] topViewController] isKindOfClass:[MessageViewController class]] ||
[[(UINavigationController *)[tabVC selectedViewController] topViewController] isKindOfClass:[AccountDetailViewController class]]){//判断哪个控制器可以滑到抽屉
shouldRecognizeTouch = YES;//返回yes表示可以滑动到左右侧抽屉
}else{
shouldRecognizeTouch = NO;
}
/*UIView * customView = [nav.topViewController view];
CGPoint location = [touch locationInView:customView];//返回触摸点在view的坐标
shouldRecognizeTouch = (CGRectContainsPoint(customView.bounds, location));//意思就是当point的位置在rect里面就返回yes,否则返回no*/
NSLog(@"shouldRecognizeTouch==%d",shouldRecognizeTouch);
}
return shouldRecognizeTouch;
}];