ViewDeck使用效果【推荐使用版本 2.4.2】
代码示例
// 导入头文件
#import "IIViewDeckController.h"
// 定义成属性(便于全局操作)
@property (nonatomic,strong) IIViewDeckController *iiViewDeckC;
// 实例化
self.iiViewDeckC = [[IIViewDeckController alloc] initWithCenterViewController:nil leftViewController:nil];
// 设置视图
self.iiViewDeckC.leftController = navLeft;
self.iiViewDeckC.rightController = navRight;
self.iiViewDeckC.centerController = centerTabVC;
self.iiViewDeckC.topController = navUp;
self.iiViewDeckC.bottomController = navDown;
// 设置视图边距,如左侧视图展示时,中间视图显示间距
self.iiViewDeckC.leftSize = 80.0;
self.iiViewDeckC.rightSize = 80.0;
self.iiViewDeckC.topSize = 80.0;
self.iiViewDeckC.bottomSize = 80.0;
// 点击中间视图时,返回中间视图
self.iiViewDeckC.panningCancelsTouchesInView = YES;
// 设置面板模式,如IIViewDeckNoPanning则不能拖动中间视图时显示其他视图
self.iiViewDeckC.panningMode = IIViewDeckDelegatePanning;
// 设置中间视图交互模式,如IIViewDeckCenterHiddenUserInteractive则点击中间视图时不能关闭已显示的其他视图
self.iiViewDeckC.centerhiddenInteractivity = IIViewDeckCenterHiddenNotUserInteractiveWithTapToClose;
// 设置代理(结合面板模式IIViewDeckDelegatePanning使用)
self.iiViewDeckC.delegate = self;
// 打开时延时动画
self.iiViewDeckC.openSlideAnimationDuration = 0.3f;
// 关闭时延时动画
self.iiViewDeckC.closeSlideAnimationDuration = 0.3f;
// 设置当前视图
self.window.rootViewController = self.iiViewDeckC;
// 实例协议代理方法 IIViewDeckControllerDelegate
#pragma mark - IIViewDeckControllerDelegate
- (BOOL)viewDeckController:(IIViewDeckController *)viewDeckController shouldPan:(UIPanGestureRecognizer *)panGestureRecognizer
{
UIViewController *centerController = viewDeckController.centerController;
if ([centerController isKindOfClass:[UITabBarController class]])
{
// 中间视图控制器为UITabBarController时,控制push进的二级及以后视图控制器不能再打开左右等视图控制器
UINavigationController *navigationCon