使用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

以下是需要注意的地方

目录
相关文章
|
8月前
|
前端开发 算法
一个有趣的图片加载效果
一个有趣的图片加载效果
69 0
|
JSON 前端开发 Android开发
Lottie 动画里有图片?有动画效果但图片加载不出来?
Lottie 动画里有图片?有动画效果但图片加载不出来?
1488 0
uwp 图片切换动画 使用帧动画
原文:uwp 图片切换动画 使用帧动画 上一篇博客使用了Timer来实现图片的切换,@lindexi_gd讨论了一下性能,我本人其实对性能这一方面不太熟,但我觉得还是有必要考虑一下,那么今天我们使用帧动画开实现以下 新建项目,添加一个Button和Image 在Page里定义资源 ...
904 0
|
JavaScript Android开发 前端开发
加载gif图片的方法:(需要SDWebImage方法)
<p style="color:rgb(51,51,51); font-family:Arial; font-size:14px"></p> <p style="margin-top:0px; margin-bottom:0px; font-size:11px; line-height:normal; font-family:Menlo; color:rgb(209,47,27)">
2861 0
|
前端开发
Glide加载圆形图片
方案1:经过验证,可以完美实现 Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { @Override prot...
839 0