我不知道如何制作动画,也不知道如何将其放入 Xcode。有人可以给我一些背景信息吗?
问问题
5695 次
2 回答
5
NSArray *animationArray = [NSArray arrayWithObjects:[UIImage imageNamed@"firstImage",[UIImage imageNamed@"secondImage",nil]; //add as many as you want
现在您需要一个 imageview 来将动画设置为:
self.myImageView.animationImages =animationArray;
self.myImageView.animationDuration = 3;
self.myImageView.animationRepeatCount = -1; //keeps going infinitely
[self.myImageView startAnimating];
于 2013-01-02T22:05:50.247 回答
0
我猜你想要做的是创建一个动画图像,而不是动画视图转换......这里是关于为 iOS 创建动画的两种方法的一些背景知识。
第一个选项:创建一个图像数组(UIImage),然后使用 startAnimating 方法。像这样的东西:
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];
第二个选项:(适用于 iOS 4 及更高版本)您可以使用基于块的方法。这是 StackOverflow 上的参考文章的链接。
此外,您可能想查看 Apple 提供的与 Core Animation 相关的文档:
于 2013-01-02T22:04:20.520 回答