IOS动画不保持最后位置

时间:2015-11-17 04:38:57

标签: ios swift animation mobile uiinterfaceorientation

我正在使用这种方法:

UIView.animateWithDuration(1.0, animations: { () -> Void in         
            self.userAndPass.alpha = 1.0
            self.userAndPass.center.y = self.userAndPass.center.y - 72            
            self.vfInicioSesion.center.y = self.vooffInicioSesion.center.y + 72
})

效果很好但是当我从纵向传递到风景或反之亦然时,元素不会保持其最后位置(它们会重置到初始位置)。

我能做些什么才能让我的元素保持最后的位置?

威利

1 个答案:

答案 0 :(得分:0)

您需要重新计算框架以及旋转界面所需的位置,并确保在旋转设备时设置新坐标。