标签:
//1.添加一个.gif类型的动态的图片,用到URLForResource方法,gif是图片的格式,FlagZombie是图片的名字
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [[NSBundle mainBundle] URLForResource:@"FlagZombie" withExtension:@"gif"];
UIImage *img = [UIImage animatedImageWithAnimatedGIFURL:url];
//创建一个UIImageView类型的对象
UIImageView *iv = [[UIImageView alloc]init];
iv.image = img;//把这个对象的image属性设置为img
iv.frame = CGRectMake(50, 50, 200, 150);
[self.view addSubview:iv];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//需要完成功能还需要在文件中添加第三方库,库在我的文件中有。
标签:
原文地址:http://www.cnblogs.com/wanghengheng/p/4814878.html