2010-10-06 91 views
3

我想旋轉設備時,改變的α爲0,以動畫我的子視圖的運動,移動視圖到新的位置和α復位到1。在IOS 4使用塊完成處理程序的動畫

使用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

也許實際上動畫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;} 
} 
}]; 

乾杯, 剋日什托夫·Zabłocki

+0

它使褪色更好,但仍然閃爍有點突然。不過謝謝。 – joec 2010-10-06 15:08:33

相關問題