2016-04-03 77 views
-2

如何在objective-c中使用UIView animateWithDuration创建左(或右)滑块菜单?如何使用UIView animateWithDuration?

- (IBAction) menuButton :(UIButton *) sender { 

[UIView animateWithDuration:1.0 animations:^{ 
    self.view.center = CGPointMake(-self.view.frame.size.width/2 + 40, self.view.center.y); 
}]; 

}

回答

1

您可以设置动画块中的视图的框架:

[UIView animateWithDuration:1.0 animations:^{ self.view.frame = CGRectMake(self.view.frame.size.width - 200, 0, self.view.frame.size.width, self.view.frame.size.height);}]; 
+0

如何添加细胞或标签对此有何看法? – Marie

+0

你的原始问题意味着你想知道如何使用animateWithDuration。如果你想要一个滑动菜单的完整实现,可以通过Google搜索获得很多好的教程。简而言之,您可以创建一个UITableView off屏幕并使用animateWithDuration将表格滑动到视图中。 – jsondwyer

相关问题