2011-07-12 46 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