【发布时间】:2013-11-29 19:57:42
【问题描述】:
我在底部显示和隐藏子视图----->顶部或顶部 ---->使用下面的代码使用 UIViewAnimation 来显示和隐藏子视图
-(IBAction)showClander
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:NO];
[UIView setAnimationDuration:0.50];
pickerView.frame = CGRectMake(0, 568-368, pickerView.frame.size.width, pickerView.frame.size.height);
[UIView commitAnimations];
}
-(void)hideClander
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:NO];
[UIView setAnimationDuration:0.50];
pickerView.frame = CGRectMake(0, pickerView.frame.origin.y+368, pickerView.frame.size.width, pickerView.frame.size.height);
[UIView commitAnimations];
}
上面的代码在我没有使用自动布局时工作正常,但是因为我的应用程序支持纵向和横向,所以我应该使用自动布局。
现在的问题是如何为这个移动视图设置不同的约束,对于静态视图,我设置了不同的约束,这对我来说很好,如下面的屏幕截图所示
如上图所示,当我尝试将 (Y 值为 371) 更改为 568(这是我的要求)时,我没有得到结果以上截图。
那么问题是有什么方法可以使用现有的约束来移动对象而不做太多的改变来实现上述结果?任何建议将不胜感激。在此先感谢
【问题讨论】:
标签: ios iphone animation autolayout