我想在旋转设备时动画我的子视图移动,将alpha更改为0,将视图移动到新位置并将alpha重置为1.
在didRotateFromInterfaceOrientation
中使用此代码会导致视图快速闪烁并淡出,然后重新出现。我想避免这种行为。
[UIView animateWithDuration:kAnimationDuration animations:^{
anObject.alpha = 0.0;
CGRect newFrame = anObject.frame;
newFrame.origin.x = newX;
newFrame.origin.y = newY;
newFrame.size.width = newWidth;
newFrame.size.height = newHeight;
anObject.frame = newFrame;
} completion:^ (BOOL finished){
if (finished) {
anObject.alpha = 1.0;
}
}];
有没有办法解决这种闪烁问题?
由于
答案 0 :(得分:4)
也许在完成时实际上是动画alpha?而不是闪光吗? :)
[UIView animateWithDuration:kAnimationDuration animations:^{
anObject.alpha = 0.0;
CGRect newFrame = anObject.frame;
newFrame.origin.x = newX;
newFrame.origin.y = newY;
newFrame.size.width = newWidth;
newFrame.size.height = newHeight;
anObject.frame = newFrame;
} completion:^ (BOOL finished){
if (finished) {
[UIView animateWithDuration:kAnimationDuration
animations:^{
anObject.alpha = 1;}
}
}];
干杯, KrzysztofZabłocki