Start CATransition at specific location - iphone

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.

Related

Paper 'Unfold' Animation on a UIView

I want to create an 'unfold' animation to a UIView that appears on the screen.
An example of the animation can be viewed in this YouTube video that reviews the SuperList app (Another example of the animation can be viewed in the app's App Store page in the screenshots section).
I have quite good understanding of Core Animation and Objective C, so as with Cocoa and Cocoa Touch. The app will support versions 5.x and 4.x of iOS so, if it is possible, I would prefer a solution that suits both cases.
Moreover, I have googled this question about a thousand times and failed to get any answers, so help will be much appreciated. Thanks ahead, iLyrical.
Apparently, the 'UnCurl' effect is built-in with the framework and is your to use!
All you have to do, is use the animateWithDuration: animation: method of the UIView class and include the animation as follows:
[UIView animateWithDuration:1.0
animations:^{
CATransition *transition = [CATransition animation];
[transition setDelegate:self];
[transition setDuration:0.7];
[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[transition setType:#"pageUnCurl"];
[self.view.layer addAnimation:transition forKey:#"pageUnCurl"];
[self.view addSubview:someView.view];
}];
The note image (white page) in this case has transparent section (all side) and thus when uncurl happens it looks like only the white part is uncurling.

iOS Core Animation Police Light Flashing Light Effect

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.

How to show iris(some says shutter) in Camera while capturing image in iPhone?

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];

corner like in maps App

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.

iPhone. CATransition fades but I want sliding

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.