【发布时间】:2014-07-21 22:06:45
【问题描述】:
我是一名初级程序员,试图在 iOS 的 Xcode 上使用 UIImageView 创建自定义 GIF。我有下面的代码,但它根本没有显示。我觉得解决方案非常简单,而且就在我面前,但我整天都在摸头,试图找出没有成功的问题。我在 sprite kit 中完成了几乎所有的游戏,并且在 MyScene 类(不是视图控制器)中完成。
UIImageView *testGIF= [[UIImageView alloc] initWithFrame:CGRectMake(self.size.width/2,self.size.height/4,100,100)];
NSMutableArray *GIFImageArray = [@[] mutableCopy];
NSString *GIFImageNames[15];
for (int i = 1; i <=15; i++) {
UIImage *GIFImage = [UIImage imageNamed:[NSString stringWithFormat:@"DragAndMatch-%i.png", i]];
GIFImageNames[i-1]=[NSString stringWithFormat:@"DragAndMatch-%i.png", i];
[GIFImageArray addObject:GIFImage];
}
testGIF.animationImages = GIFImageArray;
testGIF.animationRepeatCount = 1;
testGIF.animationDuration = 5;
[self.view addSubview: testGIF];
[testGIF startAnimating];
【问题讨论】:
标签: ios animation uiimageview animated-gif