首页 > 其他 > 详细

动态图片加到UIImageView中

时间:2015-09-17 01:04:05      阅读:427      评论:0      收藏:0      [点我收藏+]

//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

技术分享

//需要完成功能还需要在文件中添加第三方库,库在我的文件中有。

动态图片加到UIImageView中

原文:http://www.cnblogs.com/wanghengheng/p/4814878.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!