2012-04-30 41 views
0

我有一個奇怪的問題,在我的連鎖動畫之一。我有我的屏幕上的每個塊(其中26個)的塊對象,當用戶按下它們時,我執行翻轉。它的效果很好,但我在添加一個縮放動畫之前,先讓它們在屏幕上放大50%。所以,我的順序是:ios transform.rotation.y打破窗口

放大 延遲(讓用戶看大圖) 旋出90%(去除視圖塊) - 使用transform.rotation.y 變化圖像&旋入式表 收縮。

我已經設置了窗口視圖控制器作爲這些塊的委託,這樣它可以傳遞一個計數器給塊,這樣我就可以在右上方放置正確的子圖層(使用setZposition)。

這一切都很好,除非在屏幕上有兩個相互位於上方/下方的塊,這樣放大會導致它們重疊,然後當旋轉動畫開始時,它立即具有塊的右側在它下面的塊後面彈出。我已經嘗試將動畫更改爲transform.rotation.x,並在塊是並排時獲得相同的行爲。

我不確定這是否是iOS錯誤,如果我只是沒有做正確的事情。任何建議,非常感謝。這裏是分拆方法:

- (void)spinOut:(id)sender 
{ 
    NSTimeInterval animationTime=0.85; 

    [UIView animateWithDuration:animationTime 
         delay:0 
        options: UIViewAnimationOptionCurveLinear 
       animations:^{ 
        // setup the animation to spin the current view out 
        [CATransaction begin]; 
        [CATransaction setDisableActions:YES]; 
        CABasicAnimation *spinOut = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; 
        [spinOut setDelegate:self]; 
        [spinOut setDuration:animationTime]; 
        CAMediaTimingFunction *tf = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 
        [spinOut setTimingFunction:tf]; 
        [spinOut setFromValue:[NSNumber numberWithFloat:M_PI * 0.0]]; 
        [spinOut setToValue:[NSNumber numberWithFloat:M_PI * 0.5]]; 
        [spinOut setRemovedOnCompletion:NO]; 
        [spinOut setFillMode:kCAFillModeForwards]; 

        // setup variables used to roll in the next view on animation completion. 
        [pageView.layer addAnimation:spinOut forKey:kMyVeryOwnABCsSpinOutKey]; 

        [CATransaction commit]; 
       } 
       completion:^(BOOL finished){ 
        [self setFlipOutAnimationTimer:[NSTimer scheduledTimerWithTimeInterval:animationTime target:self selector:@selector(spinIn:) userInfo:nil repeats:NO]]; 
       }]; 

} 
+0

好吧 - 這是一個模糊的問題,我只是在縮小圖像之後做旋轉。我猜想夠好了。 – jpporterVA

回答

0

好的 - 這是一個老問題,但我很清楚這個問題。由於我是沿着Y軸翻轉這些圖像,所以我能夠更改動畫圖像的Zposition。在我startAnimation的方法,我說:

float pageLevelLayerPosition; 
    // logic to set the zposition variable 100 more than anything nearby 

    _originalImageViewZPosition = bigImageView.layer.zPosition; 
    [bigImageView.layer setZPosition:pageLevelLayerPosition]; 

,然後當animationDidStop,我添加的代碼中的相關行重置回它爲0,我在那裏移除動畫。我有一些代碼來管理這個變量,所以我確信這個數字比附近的任何數據都要大。

我想如果我進入三維動畫,那麼我需要更密切地控制這一點,但這是什麼導致我的問題。