How can I change the image of a UIImageView on half way of a Flip animation. My code does seem to flip the UIImageView and successfully change the image but it is changing in an
You can use UIView
class method + (void)transitionWithView:duration:options:animations:completion:
for this animation easily.
Use code like this for your animation:
[UIView transitionWithView:imageView
duration:0.4
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
// Set the new image
// Since its done in animation block, the change will be animated
imageView.image = newImage;
} completion:^(BOOL finished) {
// Do whatever when the animation is finished
}];
You can set direction of flip by replacing UIViewAnimationOptionTransitionFlipFromRight
with any of the following options:
UIViewAnimationOptionTransitionFlipFromLeft
UIViewAnimationOptionTransitionFlipFromRight
UIViewAnimationOptionTransitionFlipFromTop
UIViewAnimationOptionTransitionFlipFromBottom