我需要从UIImageview中的URL加载动画Gif图像.

当我使用普通代码时,图像没有加载.

有没有其他方法可以加载动画Gif图像?

推荐答案

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = [NSArray arrayWithObjects:    
                               [UIImage imageNamed:@"image1.gif"],
                               [UIImage imageNamed:@"image2.gif"],
                               [UIImage imageNamed:@"image3.gif"],
                               [UIImage imageNamed:@"image4.gif"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];

您可以加载多个gif图像.

您可以使用以下ImageMagick命令拆分gif:

convert +adjoin loading.gif out%d.gif

Objective-c相关问答推荐

XCTAssertEqual 错误:(3)不等于(3)

NSTimeZone:localTimeZone 和 systemTimeZone 有什么区别?

获取 Objective-C 类或实例的所有方法

iOS:将 URL 解析为段

何时使用静态字符串与 #define

UITableView 滚动事件

UITextView 禁用文本 Select

从 UIPageViewController 中移除视图控制器

iOS:如何将 UIViewAnimationCurve 转换为 UIViewAnimationOptions?

自定义 UINavigationBar 背景

Objective-C 中的 alloc、init 和 new

iOS Buttons - 添加边框

仅在 UIView 顶部的圆角

检测 UITableView 滚动

无法将 searchBar 设置为 firstResponder

在 DEBUG 模式下启用和禁用 NSLog

根据文本量更改 UITableViewCell 高度

为什么 Select Emacs/Vim/Textmate? Xcode 还不够好吗?

Objective-c - CABasicAnimation 在动画后应用更改?

@package 指令在 Objective-C 中的作用是什么?