我有一个动画,以编程方式在屏幕上向上移动三个按钮。但是,当我在iPhone 6或iPhone 4的模拟器上测试它时,按钮的位置都是错误的(但只适用于iPhone 5)。我该如何解决。这些按钮是以编程方式构建的,所以我无法真正使用自动布局将它们放置在视图控制器上。如何使用按钮动画实现自动布局
-(IBAction)Search:(id)sender {
self.button.frame = CGRectMake(124, 475, 78, 72);
self.buttonTwo.frame = CGRectMake(124, 475, 78, 76);
self.buttonThree.frame = CGRectMake(124, 475, 78, 76);
// animate
[UIView animateWithDuration:0.75 animations:^{
self.button.frame = CGRectMake(13, 403, 78, 72);
self.buttonTwo.frame = CGRectMake(124, 347, 78, 76);
self.buttonThree.frame = CGRectMake(232, 403, 78, 76);
为什么你不能使用autolayout?即使它是以编程方式创建的,你仍然可以定位它们。可以创建NSLayoutConstraints的实例。 – Joshua