加载gif图片的方法:(需要SDWebImage方法)

加载gif图片的方法:(需要SDWebImage方法)


/**

 *  加载图片

 */

- (void)initLoadingImageView

{

    NSString  *name = @"loading.gif";

    NSString  *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]] pathForResource:name ofType:nil];

    NSData  *imageData = [NSData dataWithContentsOfFile:filePath];

    

    if (!self.loadingImageView) {

        self.loadingImageView = [[UIImageView alloc]init];

    }

    //    imgView.image = [UIImage animatedImageWithAnimatedGIFData:imageData];

    self.loadingImageView.backgroundColor = [UIColor clearColor];

    self.loadingImageView.image = [UIImage sd_animatedGIFWithData:imageData];

    self.loadingImageView.frame = CGRectMake(0, 0, 100, 250/2.0);

    [self.view addSubview:self.loadingImageView];

    [self.view bringSubviewToFront:self.loadingImageView];

}


你可能感兴趣的:(加载gif图片的方法:(需要SDWebImage方法))