我想平滑地上下动画图像。任何人都知道如何做到这一点..
问问题
1177 次
3 回答
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"];
您可以使用这些值,直到获得所需的结果。如果这是您的解决方案,请接受此作为答案。
于 2012-06-01T09:52:45.343 回答
2
看一个简单的UIView(UIImageView)动画教程
iPhone 应用程序最酷的事情之一是它们中的许多应用程序的动画效果。您可以让视图飞过屏幕、淡入或淡出、淡出、旋转等等!这不仅看起来很酷,而且动画是一个很好的指标,表明用户应该注意正在发生的事情,例如更多信息可用。
于 2012-06-01T09:49:57.787 回答
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];
}
}
于 2012-06-01T14:35:25.450 回答