Dip*_*esh 30 iphone cocoa-touch facebook objective-c
Facebook iphone应用程序有一个新的侧面菜单,
屏幕http://www.tapscape.com/wp-content/uploads/2011/10/facebook2.jpg
有谁知道我如何在我的iPhone应用程序中实现此功能并使用目标c?
gre*_*sus 51
这真的很简单.首先,您需要创建一个位于可见的视图控制器下面的视图控制器.您可以将该视图发送到后面,如下所示:
[self.view sendSubviewToBack:menuViewController.view];
Run Code Online (Sandbox Code Playgroud)
然后,在导航栏的左侧放置一个菜单按钮,并编写一个类似于此的处理程序:
- (void)menuButtonPressed:(id)sender {
CGRect destination = self.navigationController.view.frame;
if (destination.origin.x > 0) {
destination.origin.x = 0;
} else {
destination.origin.x += 254.5;
}
[UIView animateWithDuration:0.25 animations:^{
self.navigationController.view.frame = destination;
} completion:^(BOOL finished) {
self.view.userInteractionEnabled = !(destination.origin.x > 0);
}];
}
Run Code Online (Sandbox Code Playgroud)
这是一般的想法.您可能必须更改代码以反映您的视图层次结构等.