Animate the CHANGE of UIImageView only one image - iphone

I have a UIImageView that I would like to change its image with animation. I checked how to animate a UIImageView with an array but I don't wanna use many image.
I just wanna change the current image with a a new one using any kind of animation only once.

I think you can find your answer on this

The animationImages property works equally well with one image in it, or multiple.

Just put the below code:
#import <QuartzCore/QuartzCore.h>
...
imageView.image = [UIImage imageNamed:"The image name"];
CATransition *transition = [CATransition animation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[imageView.layer addAnimation:transition forKey:nil];
I think you are searchig for this......

Related

iphone image change with motion

hi is there any way to set image [uiimage image named#"abc.png"] with the motion effect means the image should not be changed at once , it need to change with very slow motion effect so that user can see that image is now changing .
Thanks in advance
* Method one to perform the Animation *
Step 1 : Add following framework in your project and import it to your .m file
#import <QuartzCore/QuartzCore.h>
Step 2 : Write following code in your ImageChange method
imageView.image = [UIImage imageNamed:#"newImage.jpg"];
CATransition *transition = [CATransition animation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[imageView.layer addAnimation:transition forKey:nil];
* Method Two to perform the Animation *
[UIView transitionWithView:YourImageView
duration:0.2f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
YourImageView.image = newImage;
} completion:NULL];

Stopping CATransition animation

I'm using this code to make ripple animation for my view
transition = [CATransition animation];
transition.delegate = self;
transition.duration = 3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
NSString *types[4] = {#"cube", #"rippleEffect", #"cube", #"alignedCube"};
NSString *subtypes[4] = {kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromRight};
transition.type = types[1];
transition.subtype = subtypes[1];
Now I want to stop the animation by means of tap and after that I want to start from the view where I stopped....
I tried for
[view.layer removeAllAnimations];
But I found the following thing doesn't work ..Any Suggestions???
Set the speed of your animation to 0 to pause it and to 1 to resume it again.
Take a look at https://developer.apple.com/library/ios/#qa/qa2009/qa1673.html
You can fetch the current animation state from the CALayer.
#import <QuartzCore/QuartzCore.h>
myView.layer.modelLayer.frame = myView.layer.presentationLayer.frame;

Swapping a UIImageView's image while rotating and moving leaves traces of original image

I am taking the "Flipped Text" imageView and rotating it while moving it downwards on the screen and adjusting the frame. I am also swapping out the image for a different, but similar image.
Everything works as indicated except for the image crossfade is still showing the original position for the fade-out instead of following the movement. This screenshot shows the original, transition and end states for the animation, and clearly shows the problem.
My code looks like this (logoImage is a UIImageView):
// Swap it
self.logoImage.image = [UIImage imageNamed:#"logo.png"];
CATransition *transition = [CATransition animation];
transition.duration = duration;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.logoImage.layer addAnimation:transition forKey:nil];
// Spin it
CABasicAnimation* spinAnimation = [CABasicAnimation animationWithKeyPath:#"transform.rotation"];
spinAnimation.toValue = [NSNumber numberWithFloat:6*M_PI];
spinAnimation.duration = duration;
spinAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
spinAnimation.removedOnCompletion = YES;
spinAnimation.fillMode = kCAFillModeForwards;
[self.logoImage.layer addAnimation:spinAnimation forKey:#"spinAnimation"];
// Shrink it and Move it
CGRect newFrame = [self logoFrameForInterfaceOrientation:self.interfaceOrientation];
[UIView animateWithDuration:duration
delay:0.0
options:UIViewAnimationCurveEaseOut
animations:^{
self.logoImage.frame = newFrame;
}
completion:nil];
How can I make the crossfade of the image swap happen in place?
Try swapping the image in the completion block. (currently nil)
edit:
If they are substantially different, you can use a second UIImageView. Fade one out while you fade one in. You can either do this while they are translating, or wait for the "shrunken" original to arrive and fade it out while the "better" smaller version fades in.
Then remove the unneeded extra view in the completion block of that animation.

when cell gets selected in table view i should able to animate the cell before going to another view

CATransition *animation = [CATransition animation];
animation.type = #"suckEffect";
animation.duration = 1.0f;
animation.delegate = self;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
[[tableView cellForRowAtIndexPath:indexPath].layer addAnimation:animation forKey:#"transitionViewAnimation"];
Can any body tell me what are the other types of animations to animate the table cell.
I am selected one of these to animate rows ,tat solved my problem....
pageCurl,
pageUnCurl,
suckEffect,
spewEffect,
cameraIris (from the Photos application),
cameraIrisHollowOpen,
cameraIrisHollowClose,
genieEffect (typically used for deleting garbage),
unGenieEffect,
rippleEffect,
twist,
tubey,
swirl,
charminUltra,
zoomyIn,
zoomyOut,
oglFlip.

Animate transitions between UIViews in a container view

I have a UIView that I use as a container for four separate subviews. At any one time, only one of the subviews is visible and the rest are hidden. Right now, when switching between the views, all I am working with is setting or inserting the hidden property.
I'd like to have some sort of an animated transition to give the app a bit more polish, but can't quite make sense of some of the other posts I've read.
Could someone walk me through how to animate transitions from one subviews to another within a containing UIView?
Thanks!
Try to read about transitionFromView:toView:duration:options:completion: here
Try playing around with this code. This must be very close to what you need.
CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
self.navigationController.navigationBarHidden = NO;
[self.navigationController popViewControllerAnimated:YES]
;