3

我想在旋转设备时为我的子视图移动设置动画,将 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;
    }
}];

有没有办法解决这个闪烁?

谢谢

4

1 回答 1

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;} 
} 
}];

干杯, Krzysztof Zabłocki

于 2010-10-06T12:56:28.203 回答