You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
7.5 KiB

6 years ago
  1. <p align="center" >
  2. <img src="SDWebImage_logo.png" title="SDWebImage logo" float=left>
  3. </p>
  4. [![Build Status](http://img.shields.io/travis/rs/SDWebImage/master.svg?style=flat)](https://travis-ci.org/rs/SDWebImage)
  5. [![Pod Version](http://img.shields.io/cocoapods/v/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/)
  6. [![Pod Platform](http://img.shields.io/cocoapods/p/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/)
  7. [![Pod License](http://img.shields.io/cocoapods/l/SDWebImage.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html)
  8. [![Dependency Status](https://www.versioneye.com/objective-c/sdwebimage/badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage)
  9. [![Reference Status](https://www.versioneye.com/objective-c/sdwebimage/reference_badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage/references)
  10. [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/rs/SDWebImage)
  11. [![codecov](https://codecov.io/gh/rs/SDWebImage/branch/master/graph/badge.svg)](https://codecov.io/gh/rs/SDWebImage)
  12. This library provides an async image downloader with cache support. For convenience, we added categories for UI elements like `UIImageView`, `UIButton`, `MKAnnotationView`.
  13. ## Features
  14. - [x] Categories for `UIImageView`, `UIButton`, `MKAnnotationView` adding web image and cache management
  15. - [x] An asynchronous image downloader
  16. - [x] An asynchronous memory + disk image caching with automatic cache expiration handling
  17. - [x] A background image decompression
  18. - [x] A guarantee that the same URL won't be downloaded several times
  19. - [x] A guarantee that bogus URLs won't be retried again and again
  20. - [x] A guarantee that main thread will never be blocked
  21. - [x] Performances!
  22. - [x] Use GCD and ARC
  23. ## Supported Image Formats
  24. - Image formats supported by UIImage (JPEG, PNG, ...), including GIF
  25. - WebP format, including animated WebP (use the `WebP` subspec)
  26. ## Requirements
  27. - iOS 7.0 or later
  28. - tvOS 9.0 or later
  29. - watchOS 2.0 or later
  30. - macOS 10.9 or later
  31. - Xcode 7.3 or later
  32. #### Backwards compatibility
  33. - For iOS 5 and 6, use [any 3.x version up to 3.7.6](https://github.com/rs/SDWebImage/tree/3.7.6)
  34. - For iOS < 5.0, please use the last [2.0 version](https://github.com/rs/SDWebImage/tree/2.0-compat).
  35. ## Getting Started
  36. - Read this Readme doc
  37. - Read the [How to use section](https://github.com/rs/SDWebImage#how-to-use)
  38. - Read the [Documentation @ CocoaDocs](http://cocoadocs.org/docsets/SDWebImage/)
  39. - Try the example by downloading the project from Github or even easier using CocoaPods try `pod try SDWebImage`
  40. - Read the [Installation Guide](https://github.com/rs/SDWebImage/wiki/Installation-Guide)
  41. - Read the [SDWebImage 4.0 Migration Guide](Docs/SDWebImage-4.0-Migration-guide.md) to get an idea of the changes from 3.x to 4.x
  42. - Read the [Common Problems](https://github.com/rs/SDWebImage/wiki/Common-Problems) to find the solution for common problems
  43. - Go to the [Wiki Page](https://github.com/rs/SDWebImage/wiki) for more information such as [Advanced Usage](https://github.com/rs/SDWebImage/wiki/Advanced-Usage)
  44. ## Who Uses It
  45. - Find out [who uses SDWebImage](https://github.com/rs/SDWebImage/wiki/Who-Uses-SDWebImage) and add your app to the list.
  46. ## Communication
  47. - If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/sdwebimage). (Tag 'sdwebimage')
  48. - If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/sdwebimage).
  49. - If you **found a bug**, open an issue.
  50. - If you **have a feature request**, open an issue.
  51. - If you **want to contribute**, submit a pull request.
  52. ## How To Use
  53. * Objective-C
  54. ```objective-c
  55. #import <SDWebImage/UIImageView+WebCache.h>
  56. ...
  57. [imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
  58. placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
  59. ```
  60. * Swift
  61. ```swift
  62. import SDWebImage
  63. imageView.sd_setImage(with: URL(string: "http://www.domain.com/path/to/image.jpg"), placeholderImage: UIImage(named: "placeholder.png"))
  64. ```
  65. - For details about how to use the library and clear examples, see [The detailed How to use](Docs/HowToUse.md)
  66. ## Animated Images (GIF) support
  67. - Starting with the 4.0 version, we rely on [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) to take care of our animated images.
  68. - If you use cocoapods, add `pod 'SDWebImage/GIF'` to your podfile.
  69. - To use it, simply make sure you use `FLAnimatedImageView` instead of `UIImageView`.
  70. - **Note**: there is a backwards compatible feature, so if you are still trying to load a GIF into a `UIImageView`, it will only show the 1st frame as a static image by default. However, you can enable the full GIF support by using the built-in GIF coder. See [GIF coder](https://github.com/rs/SDWebImage/wiki/Advanced-Usage#gif-coder)
  71. - **Important**: FLAnimatedImage only works on the iOS platform. For macOS, use `NSImageView` with `animates` set to `YES` to show the entire animated images and `NO` to only show the 1st frame. For all the other platforms (tvOS, watchOS) we will fallback to the backwards compatibility feature described above
  72. ## Installation
  73. There are three ways to use SDWebImage in your project:
  74. - using CocoaPods
  75. - using Carthage
  76. - by cloning the project into your repository
  77. ### Installation with CocoaPods
  78. [CocoaPods](http://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the [Get Started](http://cocoapods.org/#get_started) section for more details.
  79. #### Podfile
  80. ```
  81. platform :ios, '7.0'
  82. pod 'SDWebImage', '~> 4.0'
  83. ```
  84. If you are using Swift, be sure to add `use_frameworks!` and set your target to iOS 8+:
  85. ```
  86. platform :ios, '8.0'
  87. use_frameworks!
  88. ```
  89. #### Subspecs
  90. There are 4 subspecs available now: `Core`, `MapKit`, `GIF` and `WebP` (this means you can install only some of the SDWebImage modules. By default, you get just `Core`, so if you need `WebP`, you need to specify it).
  91. Podfile example:
  92. ```
  93. pod 'SDWebImage/WebP'
  94. ```
  95. ### Installation with Carthage (iOS 8+)
  96. [Carthage](https://github.com/Carthage/Carthage) is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods.
  97. To install with carthage, follow the instruction on [Carthage](https://github.com/Carthage/Carthage)
  98. #### Cartfile
  99. ```
  100. github "rs/SDWebImage"
  101. ```
  102. ### Installation by cloning the repository
  103. - see [Manual install](Docs/ManualInstallation.md)
  104. ### Import headers in your source files
  105. In the source files where you need to use the library, import the header file:
  106. ```objective-c
  107. #import <SDWebImage/UIImageView+WebCache.h>
  108. ```
  109. ### Build Project
  110. At this point your workspace should build without error. If you are having problem, post to the Issue and the
  111. community can help you solve it.
  112. ## Author
  113. - [Olivier Poitrey](https://github.com/rs)
  114. ## Collaborators
  115. - [Konstantinos K.](https://github.com/mythodeia)
  116. - [Bogdan Poplauschi](https://github.com/bpoplauschi)
  117. - [Chester Liu](https://github.com/skyline75489)
  118. - [DreamPiggy](https://github.com/dreampiggy)
  119. ## Licenses
  120. All source code is licensed under the [MIT License](https://raw.github.com/rs/SDWebImage/master/LICENSE).
  121. ## Architecture
  122. <p align="center" >
  123. <img src="Docs/SDWebImageClassDiagram.png" title="SDWebImage class diagram">
  124. </p>
  125. <p align="center" >
  126. <img src="Docs/SDWebImageSequenceDiagram.png" title="SDWebImage sequence diagram">
  127. </p>