如何用DrawerLayout实现挤压的抽屉效果,求大神解
展开全部
用MMDrawerController添加下列代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[self.drawerController setGestureShouldRecognizeTouchBlock:^<a href="https://www.baidu.com/s?wd=BOOL&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">BOOL</a>(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) {
<a href="https://www.baidu.com/s?wd=BOOL&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">BOOL</a> shouldRecognizeTouch = <a href="https://www.baidu.com/s?wd=NO&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">NO</a>;
if(drawerController.openSide == MMDrawerSide<a href="https://www.baidu.com/s?wd=No&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">No</a>ne && [gesture isKindOfClass:[UIPanGestureRecognizer class]]){
UINavigationController *nav = (UINavigationController *)drawerController.centerViewController;
//判断哪个<a href="https://www.baidu.com/s?wd=%E6%8E%A7%E5%88%B6%E5%99%A8&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">控制器</a>可以滑到抽屉
if([nav.topViewController isKindOfClass:[HomeViewController class]]){
shouldRecognizeTouch = YES;
}else{
//返回yes表示可以滑动到左右侧抽屉
shouldRecognizeTouch = <a href="https://www.baidu.com/s?wd=NO&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">NO</a>;
}
}
return shouldRecognizeTouch;
}];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[self.drawerController setGestureShouldRecognizeTouchBlock:^<a href="https://www.baidu.com/s?wd=BOOL&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">BOOL</a>(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) {
<a href="https://www.baidu.com/s?wd=BOOL&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">BOOL</a> shouldRecognizeTouch = <a href="https://www.baidu.com/s?wd=NO&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">NO</a>;
if(drawerController.openSide == MMDrawerSide<a href="https://www.baidu.com/s?wd=No&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">No</a>ne && [gesture isKindOfClass:[UIPanGestureRecognizer class]]){
UINavigationController *nav = (UINavigationController *)drawerController.centerViewController;
//判断哪个<a href="https://www.baidu.com/s?wd=%E6%8E%A7%E5%88%B6%E5%99%A8&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">控制器</a>可以滑到抽屉
if([nav.topViewController isKindOfClass:[HomeViewController class]]){
shouldRecognizeTouch = YES;
}else{
//返回yes表示可以滑动到左右侧抽屉
shouldRecognizeTouch = <a href="https://www.baidu.com/s?wd=NO&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YvrHTvrH6snHNbmv7WnWKh0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPH6YnHn4nHTvrHT1njRznW0d" target="_blank" class="baidu-highlight">NO</a>;
}
}
return shouldRecognizeTouch;
}];
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询