0
votes

Is it possible to set a new center and an angle to an animation? I'm trying to build an animation to curl a page but just partially but by default this effect curls the page from bottom right to upside left. Here is a chunk of the code I'm using to animate this.

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

The end progress sets where the page will stop curling and now I would like to set in which direction the view will curl.

Thanx!

2

2 Answers

1
votes

Finally I found a solution to my problem a couple of days after asking in here. I'm going to post the code I used so that anybody can check it. Maybe it will be useful for somebody else!

// 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
votes

Sorry, I can't help you with this but I've seen a number of threads on this type of animation, and apple is keen to reject apps that are using this code as they are 'using private APIs'. See this thread on the apple forums.