1. 程式人生 > >UIImageView載入動態gif圖片

UIImageView載入動態gif圖片

NSString  *name = @"ok.gif";
NSString  *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]] pathForResource:name ofType:nil];
NSData  *imageData = [NSData dataWithContentsOfFile:filePath];
imgview = [[UIImageView alloc] initWithImage: [UIImage sd_animatedGIFWithData:imageData]];
imgview.frame = CGRectMake([UIScreen mainScreen].bounds.size.width-50, [UIScreen mainScreen].bounds.size.height/2, 50, 50);
[self.view addSubview:imgview];
[self.view bringSubviewToFront: imgview];