我一直在网上寻找标题中描述的滑动菜单的示例。我需要的是知道我应该在iphone库中找到什么项目来制作这个,我不想占用一些时间让他们写出代码但是会有一点方向感激之情?
答案 0 :(得分:2)
我们在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];
}
答案 1 :(得分:0)
This将帮助您有条不紊地开始。