【发布时间】:2011-07-29 20:22:57
【问题描述】:
我一直在网上寻找标题中描述的滑动菜单示例。我只需要知道我应该查看 iphone 库中的哪些项目来完成此操作,我不想占用别人的时间让他们写出代码,但如果有一点指导,将不胜感激?
【问题讨论】:
标签: iphone xcode cocoa-touch
我一直在网上寻找标题中描述的滑动菜单示例。我只需要知道我应该查看 iphone 库中的哪些项目来完成此操作,我不想占用别人的时间让他们写出代码,但如果有一点指导,将不胜感激?
【问题讨论】:
标签: iphone xcode cocoa-touch
我们在我们的 iphone 应用程序中创建了一个滑动抽屉,我们使用以下过程完成了这项工作:
在视图控制器的 viewDidLoad 中设置要滑动的视图的框架,带有按钮
- (void)viewDidLoad {
[super viewDidLoad];
toOpenView.frame = CGRectMake(self.view.frame.size.width, toOpenView.frame.origin.y, 0, toOpenView.frame.size.height);
}
在按钮的点击事件中添加以下代码
-(IBAction)onOpenButtonClick:(id)sender
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
if (toOpenView.frame.origin.x == self.view.frame.size.width/2)
{
toOpenView.frame = CGRectMake(self.view.frame.size.width, toOpenView.frame.origin.y, 0, toOpenView.frame.size.height);
openButton.frame = CGRectMake((self.view.frame.size.width - openButton.frame.size.width), openButton.frame.origin.y, openButton.frame.size.width, openButton.frame.size.height);
}
else
{
toOpenView.frame = CGRectMake(self.view.frame.size.width/2, toOpenView.frame.origin.y, self.view.frame.size.width/2, toOpenView.frame.size.height);
openButton.frame = CGRectMake((toOpenView.frame.size.width - openButton.frame.size.width), openButton.frame.origin.y, openButton.frame.size.width, openButton.frame.size.height);
}
[UIView commitAnimations];
}
【讨论】:
This 希望能帮助您入门。
【讨论】: