我想要平滑地上下动画图像。任何人都知道该怎么做..
答案 0 :(得分:2)
看一下简单的UIView(UIImageView)动画tutorial
关于iPhone应用程序最酷的事情之一是它们中的许多都是动画的。您可以在屏幕上看到视图,淡入或淡出,外出,旋转等等! 这不仅看起来很酷,而且动画是用户应该注意的事情的良好指标,例如更多信息可用。
答案 1 :(得分:2)
确保导入以下框架:
#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>
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"];
您可以使用这些值,直到获得所需的结果。如果这是你的解决方案,请接受这个作为答案。
答案 2 :(得分:0)
- (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];
}
}