Swift uses Sdwebimage to process remote picture resources

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.