Skip to content

Commit c91c703

Browse files
committed
update readme
1 parent 4590dc7 commit c91c703

File tree

2 files changed

+226
-5
lines changed

2 files changed

+226
-5
lines changed

README.md

Lines changed: 225 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ YYWebImage <a href="#中文介绍">中文介绍</a>
66
[![Cocoapods](http://img.shields.io/cocoapods/p/YYWebImage.svg?style=flat)](http://cocoapods.org/?q= YYWebImage)&nbsp;
77
[![Support](https://img.shields.io/badge/support-iOS%206%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)
88

9-
Asynchronous image loading framework.<br/>
10-
(It's a component of [YYKit](https://github.com/ibireme/YYKit))
9+
![ProgressiveBlur~](https://raw.github.com/ibireme/YYWebImage/master/Demo/Demo.gif
10+
)
11+
12+
YYWebImage is an asynchronous image loading framework (a component of [YYKit](https://github.com/ibireme/YYKit)).
13+
14+
It was created as an improved replacement for SDWebImage, PINRemoteImage and FLAnimatedImage.
15+
16+
It use [YYCache](https://github.com/ibireme/YYCache) to support memory and disk cache, and [YYImage](https://github.com/ibireme/YYImage) to support WebP/APNG/GIF image decode.<br/>
17+
See these project for more information.
1118

1219

1320
Features
@@ -18,6 +25,220 @@ Features
1825
- Image loading category for UIImageView, UIButton, MKAnnotationView and CALayer.
1926
- High performance memory and disk image cache.
2027
- High performance image loader to avoid main thread blocked.
28+
- Image effect: blur, round corner, resize, color tint, crop, rotate and more.
29+
30+
Usage
31+
==============
32+
33+
###Load image from URL
34+
35+
// load from remote url
36+
imageView.yy_imageURL = [NSURL URLWithString:@"http://github.com/logo.png"];
37+
38+
// load from local url
39+
imageView.yy_imageURL = [NSURL fileURLWithPath:@"/tmp/logo.png"];
40+
41+
42+
###Load animated image
43+
44+
// just replace `UIImageView` with `YYAnimatedImageView`
45+
UIImageView *imageView = [YYAnimatedImageView new];
46+
imageView.yy_imageURL = [NSURL URLWithString:@"http://github.com/ani.webp"];
47+
48+
49+
###Load image progressively
50+
51+
// progressive
52+
[imageView yy_setImageWithURL:url options:YYWebImageOptionProgressive];
53+
54+
// progressive with blur and fade animation (see the demo at the top of this page)
55+
[imageView yy_setImageWithURL:url options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];
56+
57+
58+
###Load and process image
59+
60+
// 1. download image from remote
61+
// 2. get download progress
62+
// 3. resize image and add round corner
63+
// 4. set image with a fade animation
64+
65+
[imageView yy_setImageWithURL:url
66+
placeholder:nil
67+
options:YYWebImageOptionSetImageWithFadeAnimation
68+
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
69+
progress = receivedSize / expectedSize;
70+
}
71+
transform:^UIImage *(UIImage *image, NSURL *url) {
72+
image = [image yy_imageByResizeToSize:CGSizeMake(100, 100) contentMode:UIViewContentModeCenter];
73+
return [image yy_imageByRoundCornerRadius:10];
74+
}
75+
completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
76+
if (from == YYWebImageFromDiskCache) {
77+
NSLog(@"load from disk cache");
78+
}
79+
}];
80+
81+
Installation
82+
==============
83+
84+
### Cocoapods (unavailable temporarily)
85+
86+
1. Update cocoapods to the latest version.
87+
1. Add `pod "YYWebImage"` to your Podfile.
88+
2. Run `pod install` or `pod update`.
89+
3. Import \<YYWebImage/YYWebImage.h\>
90+
91+
92+
### Carthage
93+
94+
1. Add `github "ibireme/YYWebImage"` to your Cartfile.
95+
2. Run `carthage update --platform ios` and add the framework to your project.
96+
3. Import \<YYWebImage/YYWebImage.h\>
97+
4. Notice: carthage framework doesn't include webp component, if you want to support webp, use cocoapods or install manually.
98+
99+
### Manually
100+
101+
1. Download all the files in the YYWebImage subdirectory.
102+
2. Add the source files to your Xcode project.
103+
3. Link with required frameworks:
104+
* UIKit.framework
105+
* CoreFoundation.framework
106+
* QuartzCore.framework
107+
* AssetsLibrary.framework
108+
* ImageIO.framework
109+
* Accelerate.framework
110+
* MobileCoreServices.framework
111+
* libsqlite3
112+
* libz
113+
4. Add `Vendor/WebP.framework`(static library) to your Xcode project if you want to support webp.
114+
5. Import `YYWebImage.h`.
115+
116+
117+
About
118+
==============
119+
This library supports iOS 6.0 and later.
120+
121+
122+
License
123+
==============
124+
YYImage is provided under the MIT license. See LICENSE file for details.
125+
126+
127+
<br/><br/>
128+
---
129+
中文介绍
130+
==============
21131

22-
![niconiconi~](https://raw.github.com/ibireme/YYWebImage/master/Demo/Demo.gif
23-
)
132+
YYWebImage 是一个异步图片加载框架 ([YYKit](https://github.com/ibireme/YYKit) 组件之一).
133+
134+
其设计目的是试图替代 SDWebImage、PINRemoteImage、FLAnimatedImage 等开源框架,它支持这些开源框架的几乎所有的功能,同时增加了大量新特性、并且有不小的性能提升。
135+
136+
它底层用 [YYCache](https://github.com/ibireme/YYCache) 实现了内存和磁盘缓存, 用 [YYImage](https://github.com/ibireme/YYImage) 实现了 WebP/APNG/GIF 动图的解码和播放。<br/>
137+
你可以查看这些项目以获得更多信息。
138+
139+
140+
特性
141+
==============
142+
- 异步的图片加载,支持 HTTP 和本地文件。
143+
- 支持 WebP、APNG、GIF 动画。
144+
- 支持逐行扫描、隔行扫描、渐进式图像加载。
145+
- UIImageView、UIButton、MKAnnotationView、CALayer 的 Category 方法支持。
146+
- 高性能的内存和磁盘缓存。
147+
- 高性能的图片设置方式,以避免主线程阻塞。
148+
- 常见图片处理:模糊、圆角、大小调整、裁切、旋转、色调等。
149+
150+
用法
151+
==============
152+
153+
###从 URL 加载图片
154+
155+
// 加载网络图片
156+
imageView.yy_imageURL = [NSURL URLWithString:@"http://github.com/logo.png"];
157+
158+
// 加载本地图片
159+
imageView.yy_imageURL = [NSURL fileURLWithPath:@"/tmp/logo.png"];
160+
161+
162+
###加载动图
163+
164+
// 只需要把 `UIImageView` 替换为 `YYAnimatedImageView` 即可。
165+
UIImageView *imageView = [YYAnimatedImageView new];
166+
imageView.yy_imageURL = [NSURL URLWithString:@"http://github.com/ani.webp"];
167+
168+
169+
###渐进式图片加载
170+
171+
// 渐进式:边下载边显示
172+
[imageView yy_setImageWithURL:url options:YYWebImageOptionProgressive];
173+
174+
// 渐进式加载,增加模糊效果和渐变动画 (见本页最上方的GIF演示)
175+
[imageView yy_setImageWithURL:url options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];
176+
177+
178+
###加载、处理图片
179+
180+
// 1. 下载图片
181+
// 2. 获得图片下载进度
182+
// 3. 调整图片大小、加圆角
183+
// 4. 显示图片时增加一个淡入动画,以获得更好的用户体验
184+
185+
[imageView yy_setImageWithURL:url
186+
placeholder:nil
187+
options:YYWebImageOptionSetImageWithFadeAnimation
188+
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
189+
progress = receivedSize / expectedSize;
190+
}
191+
transform:^UIImage *(UIImage *image, NSURL *url) {
192+
image = [image yy_imageByResizeToSize:CGSizeMake(100, 100) contentMode:UIViewContentModeCenter];
193+
return [image yy_imageByRoundCornerRadius:10];
194+
}
195+
completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
196+
if (from == YYWebImageFromDiskCache) {
197+
NSLog(@"load from disk cache");
198+
}
199+
}];
200+
201+
安装
202+
==============
203+
204+
### Cocoapods (还没提交,暂时不可用)
205+
206+
1. 将 cocoapods 更新至最新版本.
207+
1. 在 Podfile 中添加 `pod "YYWebImage"`
208+
2. 执行 `pod install``pod update`
209+
3. 导入 \<YYWebImage/YYWebImage.h\>
210+
211+
212+
### Carthage
213+
214+
1. 在 Cartfile 中添加 `github "ibireme/YYWebImage"`
215+
2. 执行 `carthage update --platform ios` 并将生成的 framework 添加到你的工程。
216+
3. 导入 \<YYWebImage/YYWebImage.h\>
217+
4. 注意: carthage framework 并没有包含 webp 组件。如果你需要支持 webp,可以用 Cocoapods 安装,或者手动安装。
218+
219+
### Manually
220+
221+
1. 下载 YYWebImage 文件夹内的所有内容。
222+
2. 将 YYWebModel 内的源文件添加(拖放)到你的工程。
223+
3. 链接以下 frameworks:
224+
* UIKit.framework
225+
* CoreFoundation.framework
226+
* QuartzCore.framework
227+
* AssetsLibrary.framework
228+
* ImageIO.framework
229+
* Accelerate.framework
230+
* MobileCoreServices.framework
231+
* libsqlite3
232+
* libz
233+
4. 如果你需要支持 webp,可以将 `Vendor/WebP.framework`(静态库) 加入你的工程。
234+
5. 导入 `YYWebImage.h`
235+
236+
237+
关于
238+
==============
239+
该项目最低支持 iOS 6.0。
240+
241+
242+
许可证
243+
==============
244+
YYWebImage 使用 MIT 许可证,详情见 LICENSE 文件。

YYWebImage/Cache/YYMemoryCache.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ - (void)_trimRecursively {
202202

203203
- (void)_trimInBackground {
204204
dispatch_async(_queue, ^{
205-
[self _trimToCost:self->_countLimit];
205+
[self _trimToCost:self->_costLimit];
206206
[self _trimToCount:self->_countLimit];
207207
[self _trimToAge:self->_ageLimit];
208208
});

0 commit comments

Comments
 (0)