iOS侧滑

2016-05-07  本文已影响444人  Aicher

由于项目中需要侧滑效果,找到一个差不多的demo,在前辈基础上自己加工一下,感觉还可以,用起来很方便

先上图

侧滑呈现效果有两种,

SlideAnimationTypeScale,

SlideAnimationTypeMove

手势三种,

needSwipeShowMenu;

needShowBoundsShadow;

needPanFromViewBounds;

这是用storyboard实现侧滑,tabBar控制器可以添加多个子控制器,侧滑的距离可以由DHSlideMenuController.m中的_leftViewShowWidth=250来调节,设置代码在AppDelegate.m中,由于要将DHSlideMenuController设置为根视图控制器,所以要手动启动

只要创建好对应控制器就可以实现如上效果,主要代码如下:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

UITabBarController *tabBarvc = [sb instantiateViewControllerWithIdentifier:@"tabbarvc"];

DHSlideMenuController *mainvc = [DHSlideMenuController sharedInstance];

UIViewController *leftvc = [sb instantiateViewControllerWithIdentifier:@"leftvc"];

mainvc.mainViewController = tabBarvc;

mainvc.leftViewController = leftvc;

mainvc.animationType = SlideAnimationTypeMove;

mainvc.needPanFromViewBounds = YES;

self.window.rootViewController = mainvc;

guthub地址:https://github.com/Aicher/JJSlide/

总的来说很简单,喜欢的话,别忘了github上给星哦!

上一篇 下一篇

猜你喜欢

热点阅读