IIViewDeckController的使用,左右拖拉菜单效果实现

博客园

 

IIViewDeckController的使用,左右拖拉菜单效果实现

 
很多应用里面都实现了对应的侧拉 显示隐藏的效果,看起来很符合用户体验的类似于这种
 
看起来很好看,今天去晚上搜下开源库,还是挺好用的,分享下
 
1.首先创建一个空工程,这里不在细说了...
  1. 导入这两个类
.
  1.  在appdalegate里面,:

   self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

    MainViewController* main = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];

    LeftViewController* left = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];

    RightViewController* right = [[RightViewController alloc] initWithNibName:@"RightViewController" bundle:nil];

    self.deckView = [[IIViewDeckController alloc] initWithCenterViewController:main leftViewController:left rightViewController:right];

   

    deckView.centerhiddenInteractivity = IIViewDeckCenterHiddenNotUserInteractiveWithTapToClose;

    deckView.leftLedge = 60;

    deckView.rightLedge = 60;

    self.window.rootViewController = deckView;

这样就能把中间视图,左右视图加载成功了
 
  1. 比如说在主视图里面或许你想整个按钮,点击的时间也实现左右滚动效果,这里有个小技巧
  2. 比如我们想在MainViewController里面增加一个点击按钮
 
 
这样的效果,
这个地方,首先我要在AppDelegate 里面声明

@property (strong,nonatomic) IIViewDeckController* deckView;

然后在MainViewController的对应的button事件下面这样写
 

- (IBAction)left:(id)sender {

    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;

    [appDelegate.deckView toggleLeftViewAnimated:YES];

}

OK 调用成功,QQ 音乐,什么里面都是这样的效果,看起来很好看的样子,分享下
 
 
 
原文地址:https://www.cnblogs.com/ccguo/p/3393028.html