dragon
dragon

Reputation:

Iphone page curl effect

I am using this code for Page curl effect ....Its work fine in simulator and device... But its not (setType:@"pageCurl") apple documented api , this caused it to be rejected by the iPhone Developer Program during the App Store review process:

animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0f];
animation.startProgress = 0.5;
animation.endProgress   = 1;
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:@"pageCurl"];
[animation setSubtype:@"fromRight"];
[animation setRemovedOnCompletion:NO];
[animation setFillMode: @"extended"];
[animation setRemovedOnCompletion: NO];
[[imageView layer] addAnimation:animation 
                         forKey:@"pageFlipAnimation"]; 

So i changed and using like this

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationWillStartSelector:@selector(transitionWillStart:finished:context:)];
[UIView setAnimationDidStopSelector:@selector(transitionDidStop:finished:context:)];
// other animation properties
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp 
                       forView:imageView cache:YES];
// set view properties
[UIView commitAnimations];

In this above code i want to stop the page curl effect at midway.. But i cant stop it in midway like map applications in ipod... Is this any fix for this? or Is there any apple documented methods used for page curl effect in ipod touch?

I am searching lot. but didnt get any answer ? can anyone help me? Thanks in advance..plz

Upvotes: 7

Views: 15760

Answers (4)

TheRonin
TheRonin

Reputation: 1315

I found a solution to add an UIView to UIViewController using Animation block.

m_Container is an UIView who contain my view animation (self). self is an UIView.

CAUTION : You need to have import QuartzCore

To present view with page curl animation you can use :

-(void)PresentView
{
    [UIView animateWithDuration:1.0 
                     animations:^{
                         CATransition *animation = [CATransition animation];
                         [animation setDelegate:self];
                         [animation setDuration:0.7];
                         [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
                         animation.type = @"pageCurl";
                         animation.fillMode = kCAFillModeForwards;
                         animation.endProgress = 0.65;
                         [animation setRemovedOnCompletion:NO];
                         [m_container.layer addAnimation:animation forKey:@"pageCurlAnimation"];  
                         [m_container addSubview:self];
                         ;}  
     ];    
}

And when you want hide this view you can use :

-(void)HideHelpView
{
    [UIView animateWithDuration:1.0 
                     animations:^{
                         CATransition *animation = [CATransition animation];
                         [animation setDelegate:self];
                         [animation setDuration:0.7];
                         [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
                         animation.type = @"pageUnCurl";
                         animation.fillMode = kCAFillModeForwards;
                         animation.startProgress = 0.35;
                         [animation setRemovedOnCompletion:NO];
                         [m_container.layer addAnimation:animation forKey:@"pageUnCurlAnimation"];  
                         [self removeFromSuperview];

                         ;}  
     ];

}

Upvotes: 4

Chris Pemberton
Chris Pemberton

Reputation: 146

If I may?

SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentModalViewController:sampleView animated:YES];

......

Upvotes: 9

Jan
Jan

Reputation: 21

Partial curling is officially supported since SDK 3.2. Check the sample code of Chris. More information can be found in the UIViewController Class Reference under Constants.

Upvotes: 0

kennytm
kennytm

Reputation: 523544

Must the stop-at-mide-point page curl effect be used? The easiest method is to replace page curl by a simpler animation (e.g. slide-out), or just curl the whole view up.

You may try to cheat by constructing the string at run time e.g.

[animation setType:[@"page" stringByAppendingString:@"Curl"]];

although you're still using an undocumented method.

Upvotes: 1

Related Questions