fade transition in iphone (forward and backwards) - iphone

I'm almost done coding my project and I have come across 1 to 2 problems with the fading. Here is what my code looks like
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionFade];
[animation setSubtype:kCATransitionFromRight, kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
It's telling me to set a subtype. I basically want to animate going back and going forward. I know i'm pretty close. What else am i missing from the code?

As near as I can tell -setSubtype: takes one NSString* argument.
The line:
[animation setSubtype:kCATransitionFromRight, kCATransitionFromLeft];
should probably be either:
[animation setSubtype:kCATransitionFromRight];
or:
[animation setSubtype:kCATransitionFromLeft];
EDIT: You may also want to add:
[[myView layer] addAnimation:animation forKey:#"transitionFromRight"];
to begin animating your myView object (which is a UIView or subclass).

From the transitions example you can use braces instead of , notice the correct curly braces: { around the type and subtype instead of the brackets: [:
NSString *types[4] = {kCATransitionMoveIn,
kCATransitionPush, kCATransitionReveal, kCATransitionFade};
NSString *subtypes[4] = {kCATransitionFromLeft,
kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom};

Related

pushView animation in one page iPhone application?

i have a web based application with only one view controller. i have some shortcut buttons in my app which will load some urls. what i need is a push animation as like
pushViewController each time when i click the shortCut buttons.
i have only one UIView .
so, i have found the solution myself,
push like animation for any view
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[self.view layer] addAnimation:animation forKey:#"SwitchToView1"];
thanks for your feedbacks,

How can I give Page flip effect in `UIScrollview`?

I am working on an application in which I am using UIScrollview, in that I need to use page flip effect.
How can I give Page flip effect in UIScrollview?
Note: In UIScrollview when we change Page at that time Scrolling the Page forward & backward. Can it be possible to give Page scroll effect at the time when we scroll page?
Forward flip -
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0f];
animation.startProgress = 0;
animation.endProgress = 1;
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
animation.type = #"pageCurl";
animation.subtype=#"fromRight";
animation.fillMode = kCAFillModeForwards;
[animation setRemovedOnCompletion:NO];
[animation setFillMode: #"extended"];
[animation setRemovedOnCompletion: NO];
[lyr addAnimation:animation forKey:#"WebPageCurl"];
Backward flip -
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.5f];
animation.startProgress = 0;
animation.endProgress = 1;
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
animation.type = #"pageUnCurl";
animation.subtype=#"fromRight";
animation.fillMode = kCAFillModeBackwards;
[animation setRemovedOnCompletion:NO];
[animation setFillMode: #"extended"];
[animation setRemovedOnCompletion: NO];
[lyr addAnimation:animation forKey:#"WebPageCurl"];
you can use this code when UIScrollView delegates.

UIPageViewController transition speed / duration?

Is there any way to change the default duration of the page curl transition?
It is way to fast then I wish it will be?
Thanks
Shani
Here is the way to to use default transition to curl the page and to specify the speed of the curl.
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0f];
animation.startProgress = 0.2;
animation.endProgress = 1;
if (isGoingBackward) {
[animation setType:#"pageUnCurl"];
[animation setSubtype:kCATransitionFromTop];
}
else
{
[animation setType:#"pageCurl"];
[animation setSubtype:kCATransitionFromLeft];
}
[animation setFillMode: kCAFillModeBackwards];
[self.view.layer addAnimation:animation forKey:#"animation"];

How to give page curl animation in webView?

I am working on PDF Reader application. if i display pdf file then i am not able to change font size of this.
So i display ePub file in UIWebView. But my problem is how to add page curl animation in UIWebView like iBook and kindle apps does.
I have created a UIWebView named myWebView and on clicking the button the curl effect will be shown on the webview:-
-(IBAction) nextPageAnimationForWebView{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0f];
animation.startProgress = 0.5;
animation.endProgress = 1;
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:#"pageCurl"];
//[animation setType:kcat];
[animation setSubtype:kCATransitionMoveIn];
[animation setRemovedOnCompletion:NO];
[animation setFillMode: #"extended"];
[animation setRemovedOnCompletion: NO];
[[myWebView layer] addAnimation:animation forKey:#"WebPageCurl"];
}
Please tell if this solved your answer.

Partial page curl animation

I have a working transition using UIViewAnimationTransitionCurlUp however, I would like the animation to stop halfway through, much like the Maps application...Any thoughts on how to achieve this?
In iOS 3.2 and later, you can give your UIViewController a UIModalTransitionStyle of UIModalTransitionStylePartialCurl. From the UIViewController reference, we see
typedef enum {
UIModalTransitionStyleCoverVertical = 0,
UIModalTransitionStyleFlipHorizontal,
UIModalTransitionStyleCrossDissolve,
UIModalTransitionStylePartialCurl,
} UIModalTransitionStyle;
So an example use case would be:
UIViewController *viewController;
// …create or retrieve your view controller…
// Note: The modalPresentationStyle must be UIModalPresentationFullScreen,
// and the presenter must also be a full-screen view
viewController.modalPresentationStyle = UIModalPresentationFullScreen;
viewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
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];
;}
];
}
The Maps partial curl is a private API. You can find details of how to use it in Erica Sadun's book The iPhone Developer's Cookbook, but you will get rejected from the App Store for using it.
Not sure if this will work, but the parameter to +setAnimationRepeatCount: can be a fraction.