- How to animate a image up and down smoothly. iphone [closed]
- UIImageView *someImage = .....
- CALayer *b = someImage.layer;
- // Create a keyframe animation to follow a path to the projected point
- CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"scale"];
- animation.removedOnCompletion = NO;
- // Create the path for the bounces
- CGMutablePathRef thePath = CGPathCreateMutable();
- // Start the path at my current location
- CGPathMoveToPoint(thePath, NULL, someImage.center.x, someImage.center.y);
- CGPathAddLineToPoint(thePath, NULL,20, 500.0);
- animation.path = thePath;
- animation.speed = 0.011;
- animation.repeatCount = 1000000;
- // Add the animation to the layer
- [someImage addAnimation:animation forKey:@"move"];
- - (void) showProgressView
- {
- if (progressViewBack.frame.origin.y == 460.0)
- {
- [self.view bringSubviewToFront:progressViewBack];
- [progressViewBack setFrame:CGRectMake(6.0, 460, 308.0, 126.0)];
- [progressViewBack setBounds:CGRectMake(0, 0, 308, 126.0)];
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:1.0];
- [UIView setAnimationDelegate:self];
- [progressViewBack setFrame:CGRectMake(6.0, 334.0, 308.0, 126.0)];
- [UIView commitAnimations];
- }
- else if (progressViewBack.frame.origin.y == 334.0)
- {
- [progressViewBack setFrame:CGRectMake(6.0, 334.0, 308.0, 126.0)];
- [progressViewBack setBounds:CGRectMake(0, 0, 308.0, 126.0)];
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:1.0];
- [UIView setAnimationDelegate:self];
- [progressViewBack setFrame:CGRectMake(6.0, 460.0, 308.0, 126.0)];
- [UIView commitAnimations];
- }