【发布时间】:2015-01-12 23:11:42
【问题描述】:
我试图在按下按钮时将文本字段向右移动。它工作正常,但是当我单击另一个文本字段或任何其他元素时,文本字段会重新出现在其当前位置。我浏览了互联网,发现当我没有启用自动布局时它可以工作,但是我需要自动布局来设置可变位置。有什么建议吗?这是移动盒子的方法:
- (IBAction)EnterInfo:(id)sender {
CGRect newFrame = _UsernameField.frame;
newFrame.origin.x += 500; // shift right by 500pts
[UIView animateWithDuration:1.0
animations:^{
_UsernameField.frame = newFrame;
}];
}
最后一个问题的新代码:
- (IBAction)EnterInfo:(id)sender {
[UIView animateWithDuration:1.0
animations:^{
_usernameX.constant = 130;
}];
}
【问题讨论】:
标签: ios objective-c animation