Question

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?

Was it helpful?

Solution

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).

OTHER TIPS

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};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top