使用目标 c 的 iphone facebook 侧边菜单 [英] iphone facebook side menu using objective c
问题描述
可能的重复:
(来源:tapscape.com)
有谁知道我如何在我的 iphone 应用程序中实现这个功能并使用目标 c?
其实很简单.首先,您需要创建一个位于可见控制器下方的视图控制器.您可以像这样将该视图发送到后面:
[self.view sendSubviewToBack:menuViewController.view];
然后,您在导航栏的左侧放置一个菜单按钮,并编写类似如下的处理程序:
- (void)menuButtonPressed:(id)sender {CGRect 目的地 = self.navigationController.view.frame;如果 (destination.origin.x > 0) {目的地.origin.x = 0;} 别的 {目的地.origin.x += 254.5;}[UIView animateWithDuration:0.25 动画:^{self.navigationController.view.frame = 目的地;}完成:^(BOOL完成){self.view.userInteractionEnabled = !(destination.origin.x > 0);}];}
这是大体的想法.您可能需要更改代码以反映您的视图层次结构等.
Possible Duplicate:
What's the best way to develop a sideswipe menu like the one in Facebook's new iOS app?
The facebook iphone app has a new side menu,
(source: tapscape.com)
Does anyone know how i can implement this feature in my iphone application and using objective c?
It's pretty simple really. First, you need to make a view controller that sits under the one that's visible. You can send that view to the back like this:
[self.view sendSubviewToBack:menuViewController.view];
Then, you put a menu button on the left side of your navigation bar, and write a handler kind of like this:
- (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);
}];
}
That's the general idea. You may have to change the code to reflect your view hierarchy, etc.
这篇关于使用目标 c 的 iphone facebook 侧边菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!