Shishir.bobby
Shishir.bobby

Reputation: 10984

curl effect on landscape mode

i am trying to implement curl effect by using below code snippet

curl down

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.95];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
 forView:self.view cache:YES];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];

curl up

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.95];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];

but this works fine with portrait mode.

I want to implement it on landscape mode, taping on top right and bottom left.

currently its working in reverse effect.

Many Thanks

Upvotes: 0

Views: 609

Answers (2)

Dev
Dev

Reputation: 390

please,try this way.i used in view navigation by one View

1st view to go next Infoview i creat the curlup effect:

InfoView *objdb=[[InfoView alloc] initWithNibName:@"InfoView" bundle:nil];
[UIView beginAnimations:nil context:NULL ];
[UIView setAnimationCurve:UIViewAnimationTransitionCurlUp];
[UIView setAnimationDuration:1.0];
[self presentModalViewController:objdb animated:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[objdb release];

then back from infoview to main view then use this(curl down effect):

[UIView  beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationTransitionCurlDown];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self dismissModalViewControllerAnimated:YES];
[UIView commitAnimations];

i hope it's help for u.

Upvotes: 1

Kuldeep
Kuldeep

Reputation: 2589

#import <QuartzCore/QuartzCore.h>

-(void)pageCurltoNextorPrevious:(UIView*)view:(int)identifier {

// Curl the image up or down
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0];
CAMediaTimingFunction *fun=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[animation setTimingFunction:fun];


if (identifier==1){
    //next animation
    animation.type = @"pageCurl";
    animation.subtype=@"fromRight";
    animation.fillMode = kCAFillModeForwards;
    animation.endProgress = 1.0; //0.58;
} 
else {
    //previous animation
    animation.type = @"pageCurl";
    animation.subtype=@"fromLeft";
    animation.fillMode = kCAFillModeBackwards;
    animation.startProgress = 0.0;
}
[animation setRemovedOnCompletion:NO];

//[view exchangeSubviewAtIndex:0 withSubviewAtIndex:2];

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

Upvotes: 2

Related Questions