ios SDWebImage 图片加载显示菊花

之前一直不知道怎样给图片加载的时候显示菊花, 都用placeholder来代替了, 原来SDWebImage 自带这个功能:

// 只要在加载图片的位置这么写就行了:
 __block UIActivityIndicatorView *activityIndicator;
    [cell.imgView sd_setImageWithURL:url placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSInteger receivedSize, NSInteger expectedSize) {
        if (!activityIndicator)
        {
            [cell.imgView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]];
            activityIndicator.center = cell.imgView.center;
            [activityIndicator startAnimating];
        }
        
    } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        
        [activityIndicator removeFromSuperview];
        activityIndicator = nil;
    }];
// 这里是在cell中给imageView附上图片的.

  

效果就是这个样子啦, 因为我的每个cell是由一个imageView 和 一个Label 组成的 但是我把菊花显示在中间了 这里坐标没有算 看起来可能会有些偏 , 自己算一下就好了

posted @ 2015-02-22 20:31  Mr.Greg  阅读(1322)  评论(0编辑  收藏  举报