2011-07-12 83 views
0

是否可以設置新的中心和動畫角度? 我試圖建立一個動畫來捲曲頁面,但只是部分,但默認情況下,這種效果卷頁從右下角到左上角。 以下是我用來爲此設置動畫的一段代碼。更改動畫的中心和角度

- (IBAction)curlUp{ 
// Curl the image up or down 
CATransition *animation = [CATransition animation]; 
[animation setDelegate:self]; 
[animation setDuration:0.35]; 
[animation setTimingFunction:UIViewAnimationCurveEaseInOut]; 

if (!curled){ 
    animation.type = @"pageCurl"; 
    animation.fillMode = kCAFillModeForwards; 
    animation.endProgress = 0.78; 
} else { 
    animation.type = @"pageUnCurl"; 
    animation.fillMode = kCAFillModeBackwards; 
    animation.startProgress = 0.42; 
} 
[animation setRemovedOnCompletion:NO]; 
[[self view] exchangeSubviewAtIndex:4 withSubviewAtIndex:5]; 

[[[self view] layer] addAnimation:animation forKey:@"pageCurlAnimation"]; 

// Disable user interaction where necessary 
if (curled) { 
    [[self view] exchangeSubviewAtIndex:4 withSubviewAtIndex:5]; 
    [[[[self view] subviews] lastObject] removeFromSuperview]; 
    } else {[self.view addSubview:ofertasCompraViewController.view]; 
    [self.view bringSubviewToFront:self.view]; 
    //[self.navigationController.navigationBar setUserInteractionEnabled:YES]; 
    //[self.view setUserInteractionEnabled:YES]; 
} 
curled = !curled; 
} 

結束進度集合,其中的頁面將停止冰壺,現在我想設置在哪個方向視圖將捲曲。

Thanx!

回答

1

最後我在這裏問了幾天後發現了一個解決方案。我將發佈我使用的代碼,以便任何人都可以檢查它。也許它會對別人有用!

// Curl the image up or down 
CATransition *animation = [CATransition animation]; 
[animation setDelegate:self]; 
[animation setDuration:0.35]; 
[animation setTimingFunction:UIViewAnimationCurveEaseInOut]; 

if (!curled){ 
    animation.type = @"pageCurl"; 
    animation.fillMode = kCAFillModeForwards; 
    animation.subtype = kCATransitionFromLeft; 
    animation.endProgress =0.75; 
} else { 
    animation.type = @"pageUnCurl"; 
    animation.fillMode = kCAFillModeBackwards; 
    animation.subtype = kCATransitionFromLeft; 
    animation.startProgress = 0.42; 
} 
[animation setRemovedOnCompletion:NO]; 
if(cambioVista) 
[[self view] exchangeSubviewAtIndex:4 withSubviewAtIndex:5]; 

[[[self view] layer] addAnimation:animation forKey:@"pageCurlAnimation"]; 
0

對不起,我無法幫助你,但是我已經看到了這類動畫的一些線索,蘋果熱衷於拒絕使用這些代碼的應用程序,因爲它們'使用私有API'。在蘋果論壇上查看thread