tags:

views:

449

answers:

1

Hello all,

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

A: 

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