问题描述
我试图找到一个原因的UIView
动画变换属性的iOS 8看起来不同于iOS的6/7。
I'm trying to find a reason why animation of UIView
transform property looks different in iOS 8 than iOS 6/7.
的举个简单的例子,之前到iOS 8:的
myView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, 1.57);
[UIView animateWithDuration:5 animations:^{
myView.transform = CGAffineTransformTranslate(plane.transform, 100, 0);
}];
给出了预期的结果,MyView的旋转90度,向下移动,但在iOS8上,当翻译动画它开始于我无法找到解释(它打破了动画)。
gives expected result, "myView" is rotated 90 degrees and moves down, but in iOS8 when translation is animated it starts at a point that I couldn't find explanation for (which breaks the animation).
有谁知道它的解释?在此先感谢!
Does anyone know the explanation for it? Thanks in advance!
推荐答案
CGAffineTransformIdentity行为不同的ios7和iOS8上。这与自动布局和大小班做。解决的办法是去除约束,与上ios7动画冲突
CGAffineTransformIdentity behaves differently on ios7 and ios8. This has to do with auto-layout and size classes. The solution is to remove constraints that conflict with the animation on ios7.
// solve the constraint-animation problem
if(NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) {
// iOS7 remove constraints that conflict with animation
if (self.centerYAlignment != nil) {
self.view.removeConstraint(self.centerYAlignment) //is an IBOutlet
}
} else {
// iOS8 constraint animations are fine
}
这篇关于在iOS8上CGAffineTransform动画看起来比在iOS7不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!