First Step: Configure Sdwebimage
Open github,https://github.com/rs/sdwebimage, download sdwebimage to local
Create a swift Singleview project with Xcode, drag the sdwebimage into the project,
Click to open the general of the project properties and add the reference frame in embedded binaries
Compile the program to make sure there are no errors. Since the library is written in OC, it needs to be bridged to Swift. The steps are this:
Add an H file to our project named "Sdwebimage+header.h", open the header file, and introduce the WebImage.h
Note that the path is not written incorrectly. After you add the bridge Connector file, you need to open the project properties, click the Build setting option, scroll to the bottom of the page to find the following properties:
Add a relative path to my bridging file at the back:
After completion, compile once, if there is no error, it is possible to use Sdwebimage in swift, the Viewcontroller input SD can be Webimage library related methods and types of
Step two: Use Sdwebimage in Swift
I put an image on the Apache server:
Let URL = "Http://192.168.1.107/jimmy.jpg", listed below are a few common methods
The client reads the picture and caches it:
The client can pre-download the picture and need to read it directly from the Local:
Clear Cached Pictures:
Swift uses Sdwebimage to process remote picture resources