NSString *name = @"qianming.gif"; NSString *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]] pathForResource:name ofType:nil]; NSData *imageData = [NSData dataWithContentsOfFile:filePath]; self.qianMingImgView.backgroundColor = [UIColor clearColor]; [self.qianMingImgView setBackgroundImage: [UIImage sd_animatedGIFWithData:imageData] forState:UIControlStateNormal];
以上方法是实用sdwebimage第三方库