改变动画的中心和角度

时间:2011-07-12 10:35:58

标签: iphone objective-c cocoa-touch ipad

是否可以为动画设置新的中心和角度? 我正在尝试构建一个动画来卷曲页面但只是部分但是默认情况下这个效果会将页面从右下角卷曲到左上角。 这是我用来制作动画的一大块代码。

- (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;
}

结束进度设置页面停止卷曲的位置,现在我想设置视图卷曲的方向。

感谢名单!

2 个答案:

答案 0 :(得分: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"];

答案 1 :(得分:0)

很抱歉,我对此无法帮助你,但我已经看到了这类动画的一些主题,而且苹果热衷于拒绝使用此代码的应用,因为他们正在“使用私有API”。在Apple论坛上查看此thread