2012-12-14 69 views
0

我有一個CATransform3D動畫,旨在替換當前在我的應用中使用的Push動畫。目前,它旋轉,就好像X軸位於圖層/視圖的中心一樣。但是,我希望X軸位於屏幕邊緣,以便它翻轉出屏幕。我當前的代碼是: -CATransform3D動畫集X軸

[UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:0.5]; 
    CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; 
    rotationAndPerspectiveTransform.m34 = 1.0/500; 
    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 1.57, 0, 1, 0); 
    self.view.layer.transform = rotationAndPerspectiveTransform; 
    [UIView commitAnimations]; 

我新的核芯顯卡和這樣的,所以任何指針,提示,我要去哪裏錯將不勝感激!

回答

1

您應該更改圖層的anchorPoint。在beginAnimations:context:方法之前使用下面的一段代碼。

CGRect frame = self.view.layer.frame; 
self.view.layer.anchorPoint = CGPointMake(1.f, 0.5f); 
self.view.layer.frame = frame; 

這將更改圖層的anchorPoint而不更改圖層位置。旋轉動畫將圍繞從錨點傳遞的軸進行。

+0

這會導致圖層向下移動到屏幕的右下角。我希望它保持在同一個位置,但它有生氣,就像翻頁一樣。 – Giz

+0

我通過將anchorPoint設置爲0.f,0.f來獲得它的工作。如果您編輯的答案反映了這一點,我很樂意投票。 – Giz