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

有办法绕过这个闪光点吗?
谢谢

最佳答案

也许真的能让阿尔法完成动作?而不是闪现?:)

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

干杯,
克孜兹托夫扎布科基

关于objective-c - 在iOS 4中为动画使用块完成处理程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3872025/

10-11 08:00