0

I am looking for a sample code to implement the easing function in iPhone. I have a set of images getting animated over an UIImageView.

what I want to do is use some ease function to make them look like bouncing.

For example on click , a balloon gets bigger from previous size with a curve.

Like lets say from size 50X50 its gets to 100X100 but while animating it also becomes 120X120 and comes back to 100X100

tnx

rkb
  • 10,933
  • 22
  • 76
  • 103
  • What exactly are u trying to do hav a bounce effect when ur image shrinks back? – Daniel Aug 04 '09 at 23:36
  • I want to have a bounce effect when the image reaches to its original size. Like as I said from 50 to 100 but it becomes 120 and comes back to 100. – rkb Aug 05 '09 at 14:41
  • Possible duplicate: http://stackoverflow.com/questions/5161465/how-to-create-custom-easing-function-with-core-animation – Martin Wickman Jun 04 '11 at 10:10

1 Answers1

0

There is no easy way to that dude :P

I looking for this one time too, i found one work around to do that:

Using one sequence of animations:

//getting image
UIImageView *newImageView = [[UIImageView alloc] initWithImage:@"yourtargetimage.png"];
//Setting the initial size of image to 0.01 (invisible)
[newImageView setTransform:CGAffineTransformMakeScale(0.01, 0.01)];

[UIImageView beginAnimations:nil context:newImageView];
            [UIImageView setAnimationDuration:0.25];
            [UIImageView setAnimationDelegate:self];
            [UIImageView setAnimationDidStopSelector:@selector(bounceBackButton:finished:context:)];

            [UIImageView setAnimationDelay:0.2*count];
            CGAffineTransform transformGrow = CGAffineTransformMakeScale(1.2, 1.2);
            newImageView.transform = transformGrow;
            [UIView commitAnimations];


- (void)bounceBackButton:(NSString *)animationID finished:(NSNumber *)finished context:(UIImageView *)imagesHolder
{
    [UIImageView beginAnimations:nil context:imagesHolder];
    [UIImageView setAnimationDuration:0.15];
    [UIImageView setAnimationDelegate:self];
    CGAffineTransform transformBack = CGAffineTransformMakeScale(1.0, 1.0);
    imagesHolder.transform = transformBack;
    [UIView commitAnimations];
}

you need to set you initial animation state, make hin go to the target size plus one bouce, and go back to the state of 1.0;

baDa
  • 57
  • 1
  • 6