首页 > Web开发 > 详细

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

时间:2014-10-05 08:12:28      阅读:1982      评论:0      收藏:0      [点我收藏+]

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

bubuko.com,布布扣

效果:

bubuko.com,布布扣

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

bubuko.com,布布扣

找到它修改文件的地方:

bubuko.com,布布扣

以下是使用源码:

//
//  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

以下是需要注意的地方

bubuko.com,布布扣

 

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

原文:http://www.cnblogs.com/YouXianMing/p/4006662.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!