使用SDWebImage淡入淡出的方式加载图片

简介:

使用SDWebImage淡入淡出的方式加载图片

效果:

请通过以下方式下载源码:

找到它修改文件的地方:

以下是使用源码:

//
//  ViewController.m
//  SDWebImageFade
//
//  Created by YouXianMing on 14-10-5.
//  Copyright (c) 2014年 YouXianMing. All rights reserved.
//

#import "ViewController.h"
#import "UIImageView+WebCache.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSString *picUrl = @"http://th04.deviantart.net/fs70/PRE/i/2014/277/4/b/cheetahr_by_harpiya-d81l8iv.jpg";
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:imageView];
    
    [imageView setImageWithURL:[NSURL URLWithString:picUrl]
              placeholderImage:nil
                       options:SDWebImageCacheMemoryOnly
                      progress:^(NSInteger receivedSize, NSInteger expectedSize) {
                          NSLog(@"%.2f", (float)receivedSize / (float)expectedSize);
                      }
                     completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
                         
                     }];
}

@end

以下是需要注意的地方

目录
相关文章
加载图片
加载图片性能,滑动速度、缩略图、内存分配
639 0
|
JSON 前端开发 Android开发
Lottie 动画里有图片?有动画效果但图片加载不出来?
Lottie 动画里有图片?有动画效果但图片加载不出来?
2069 0
|
JavaScript Android开发
在UIWebView中加载本地图片
NSString *imagePath = [[NSBundle mainBundle] resourcePath]; imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/...
747 0
|
Android开发
Android系统详解之获取图片和视频的缩略图
从Android 2.2开始系统新增了一个缩略图ThumbnailUtils类,位于framework的android.media.ThumbnailUtils位置,可以帮助我们从mediaprovider中获取系统中的视频或图片文件的缩略图,该类提供了三种静态方法可以直接调用获取。
1018 0
|
缓存 存储 iOS开发
imageNamed与imageWithContentsOfFile加载图片的区别
<p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; line-height:26px; border:0px"> <span style="font-family:'Comic Sans MS'; font-
1331 0

热门文章

最新文章