CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[animation setDelegate:self];
[[self layer] addAnimation:animation forKey:#"popUpAni"];
The above code (contained within an object of UIView class) fades the view in. I want it to slide in, not fade.
No matter what I try:
[animation setType:kCATransitionMoveIn];
[animation setSubtype:kCATransitionFromTop];
The result remains the same. Am I doing something wrong?
EDIT: Sorry, I had that backwards, I meant to say the curlup animation shows as a fade animation on the simulator...
I know for sure the slide animation, just as you've written it, works on the simulator and of course the device. The code in my project is practically verbatim to yours.
Try changing the key you specify in the addAnimation method from "popUpAni" to something else. If that key is used somewhere else in your project, it may be causing this issue.
Also, have you confirmed you are using the correct version of the CoreAnimation Framework? You should be referencing and the QuartzCore.framework reference should be looking within the iPhoneOS frameworks folder.
Related
EDIT: Per the provided comments, I have specified my question to a more direct implementation and desired solution.
Hello there,
I want a blue light, a red light, and potentially a neutral colored light, all appearing to be spinning in circles (similar to if a police car was nearby, you would see the lights flashing/rotating colors).
Here's a screenshot of the red and blue image views that I'm currently using to try to make the effect.
The following code currently varies each view layer's opacity:
[UIView animateWithDuration:4.5
delay: 1.0
options: UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveLinear
animations:^{
[self startRedAnimation];
[self startBlueAnimation];
}
completion:^(BOOL finished){}];
My animation method looks like the following:
- (void)startRedAnimation
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:#"opacity"];
[animation setFromValue:[NSNumber numberWithFloat:0.75]];
[animation setToValue:[NSNumber numberWithFloat:0.1]];
[animation setDuration:0.5f];
[animation setTimingFunction:[CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionLinear]];
[animation setAutoreverses:YES];
[animation setRepeatCount:16];
[[_redLightView layer] addAnimation:animation forKey:#"opacity"];
}
You can imagine that the blueLightView animation method looks similar.
What I'm looking for is to have the views appear to rotate, IE they are not just flashing their opacity from 0 to 1, but rather altering color and/or rotating around in a circle on the view.
I'd like to use QuartzCore and CoreAnimation frameworks to make this happen, instead of just UIView animations over an array of images.
I'm relatively new to CoreAnimation and have performed similar effects like rotating/pulsing view layers, but I'm just not certain what I could use from the framework that would give me the effect I'm looking for.
Any insight would be greatly appreciated! Thanks Stack Overflow peers!
Try to move the images instead of changing the colors. I could imagine that you could achieve the desired effect by rotating the images around the bottom of the screen back and forth.
I know this question was asked here many times before but I am still not sure whether apple will reject the app if I used "pageCurl" and "pageUncurl" animation types.
I found some very old links mentioning their app got rejected but it was before SDK 3.2 and I also come to know that in SDK 3.2 apple allowed this animation.
I think based on research apple might not reject it but I am looking for someone who can confirm this based on facts.
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:0.45f];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
if (!curled){
animation.type = #"pageCurl";
animation.fillMode = kCAFillModeForwards;
animation.endProgress = 0.58;
} else {
animation.type = #"pageUnCurl";
animation.fillMode = kCAFillModeBackwards;
animation.startProgress = 0.42;
}
[animation setRemovedOnCompletion:NO];
[[mCurlPage layer] addAnimation:animation forKey:#"pageFlipAnimation"];
Thanks
I know this is a pretty old post, but we have actually had an app, in the Store for some months now, which uses this animation.
It seems that Apple might allow it even though it is not officially supported.
after lot of googling I have dropped the plan to use pageCurl and pageUncurl API in my iphone app since there is no app which have this API and is approved in app store. hopefully apple will enable this API in future.
I have implemented camera in iPhone and taking images and save it in PhotoAlbum.
Now what i want is when i save one image and make button enable for taking second image i want iris to be shown in between.So that it feels excatly like Camera functionality of iPhone.
How i do that please give some suggestion.
Thanks
Apps like Stachematic and Zombiematic actually got away with using this private API ...
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:0.3];
animation.timingFunction = UIViewAnimationCurveEaseInOut;
[animation setType:#"cameraIris"];
[cameraView.layer addAnimation:animation forKey:nil];
I need a corner like in the Maps app.
I tried this code but nothing happens:
- (IBAction) performCurl {
// Curl the image up or down
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0f];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:(notCurled ? #"mapCurl" : #"mapUnCurl")];
[animation setRemovedOnCompletion:NO];
[animation setFillMode: #"extended"];
[animation setRemovedOnCompletion: NO];
notCurled = !notCurled;
[[topView layer] addAnimation:animation forKey:#"pageFlipAnimation"];
}
This my test-project: http://isolute.de/downloads/cornertest2.zip
This was made available in iOS 3.2 and later
UIModalTransitionStylePartialCurl
When the view controller is presented, one corner of the current view curls up to reveal the modal view underneath. On dismissal, the curled up page unfurls itself back on top of the modal view. A modal view presented using this transition is itself prevented from presenting any additional modal views.
This transition style is supported only if the parent view controller is presenting a full-screen view and you use the UIModalPresentationFullScreen modal presentation style. Attempting to use a different form factor for the parent view or a different presentation style triggers an exception.
Available in iOS 3.2 and later.
Declared in UIViewController.h.
See the answer to another question for one solution.
Note however that this answer uses [animation setRemovedOnCompletion: NO]. According to a forum post, apps have been rejected for using this undocumented API method.
Also, the mapCurl animation type is undocumented, and apps have been rejected for using it as well.
I have a CATransition (code below) that moves a view down. How can I specify a location for the animation to start, for example 60, 30.
Here's the code I'm currently using:
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
Write your own timing function that does what you want?
EDIT: I was originally suggesting that you subclass CAMediaTimingFunction, but it looks like that might not do the right thing. Instead, try experimenting with setting CATransition.startProgress, though it's a value in [0,1], not a number of pixels (if you're using a linear animation then it should be easy to convert).
I'm still not entirely sure what you mean by "a location for the animation to start", though — transitions apply to the entire view bounds. Normal UIView animations may be more likely to do what you want. If you give more details, it's easier to figure out what the problem you're trying to solve is.