博客园
IIViewDeckController的使用,左右拖拉菜单效果实现
- 导入这两个类
- 在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;
- 比如说在主视图里面或许你想整个按钮,点击的时间也实现左右滚动效果,这里有个小技巧
- 比如我们想在MainViewController里面增加一个点击按钮
@property (strong,nonatomic) IIViewDeckController* deckView;
- (IBAction)left:(id)sender {
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.deckView toggleLeftViewAnimated:YES];
}