我是一个非常初级的程序员,正在尝试找到最简单的方法来实现这一点。我以前从未涉及过动画。我想尝试在我的应用程序中对图像进行动画处理,但遇到了一些问题。这是有人先前建议我使用的代码(来自另一个问题):
imageView.image = yourLastImage;
// Do this first so that after the animation is complete the image view till show your last image.
NSArray * imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"image1.png"],
[UIImage imageNamed:@"image2.png"],
[UIImage imageNamed:@"image3.png"],
[UIImage imageNamed:@"image4.png"],
nil];
// Note: here you may instead want to use something like [UIImage imageWithContentsOfFile:[self localImagePath:NO]] instead depending upon your targeted iOS version.
UIImageView * animatedImageView = [[UIImageView alloc] initWithFrame:
CGRectMake(100, 125, 150, 130)];
animatedImageView.animationImages = imageArray;
animatedImageView.animationDuration = 1.1;
myAnimation.animationRepeatCount = 1;
animatedImageView.contentMode = UIViewContentModeBottomLeft;
[self.view addSubview:animatedImageView];
[animatedImageView startAnimating];
首先,这是否实际可行?我想要制作一个从屏幕中间到底部移动的动画。这是否意味着我必须有500张图片,每张图片之间相距1像素?什么是最佳像素间隔,使其看起来流畅均匀且不需要大量工作?有比上述方法更好的动画方式吗?是否有可以帮助制作动画并将其添加到Xcode中的程序?
此外,有人能解释一下上面的代码吗?我是新手,真的不太明白所有那些东西是什么意思。
如果这是一个愚蠢的问题,我对此感到抱歉。我在开头说过我是初学者。谢谢您所提供的任何帮助!
(void(^)(BOOL completion)
的此方法。这是代码片段:http://pastebin.com/wfGTrLu9 - Tomasz SzulcUIView
。如果您想要移动一张图片,您需要将图片放置在一个UIImageView
中,然后像示例项目中移动UIView
一样移动UIImageView
。 - MaxGabrielUIViewController
子类作为根视图控制器。请参见链接的Github项目以获取示例。这是您需要了解的关于iOS最基本的知识--我强烈建议在学习动画之前先去http://www.stanford.edu/class/cs193p/cgi-bin/drupal/学习iOS基础知识。 - MaxGabriel