説明なし

lixiang1994 7c63c10eb0 修复 6 年 前
.github 539f244ea5 Fixed Typo in report 7 年 前
Demo 799b4d15f8 优化options设置, 增加是否模糊处理, 是否等待扫描完成, 是否快速扫描, 扫描最小间隔等设置, 增加Provider类强化封装 重构相关扩展, 并完善Demo页面 6 年 前
Kingfisher.xcodeproj 10074ab96a 调整 6 年 前
Kingfisher.xcworkspace 3bde20c79b Refactor for animated image creating 7 年 前
Pods 40ab19253d 图片下载增加接收数据回调 6 年 前
Sources 7c63c10eb0 修复 6 年 前
Tests 192a0fa68a Improve test stability 6 年 前
fastlane d15d190bfb Update test script 6 年 前
images 1869184c7b Protocol indicator 9 年 前
.gitignore d1b69714fd Improve docs and fix typos 7 年 前
.ruby-version 899bd5fc91 Improve test combination 7 年 前
.travis.yml 3eb87c23f6 CI build matrix 7 年 前
CHANGELOG.md 7f70878530 Bump version to 5.4.0 6 年 前
CONTRIBUTING.md 33ef6a6aa1 Update CONTRIBUTING.md 8 年 前
Gemfile 47c662136b Use cocoapods 1.7 for linting 6 年 前
Gemfile.lock 700d460e69 Upgrade gem 6 年 前
Kingfisher.podspec 7f70878530 Bump version to 5.4.0 6 年 前
LICENSE 85e2c437a9 Happy new year 8 年 前
Package.swift 77bec276b7 Update SwiftPM manifest file 6 年 前
Podfile ead0a7293b Refactor project settings and indicator 7 年 前
Podfile.lock 40ab19253d 图片下载增加接收数据回调 6 年 前
README.md e6663b253b [README] Add 'Accio supported' badge 6 年 前
codecov.yml b698e8d622 Add codecov.yml 9 年 前

README.md

Kingfisher

codebeat badge

Kingfisher is a powerful, pure-Swift library for downloading and caching images from the web. It provides you a chance to use a pure-Swift way to work with remote images in your next app.

Features

  • Asynchronous image downloading and caching.
  • Loading image from either URLSession-based networking or local provided data.
  • Useful image processors and filters provided.
  • Multiple-layer hybrid cache for both memory and disk.
  • Fine control on cache behavior. Customizable expiration date and size limit.
  • Cancelable downloading and auto-reusing previous downloaded content to improve performance.
  • Independent components. Use the downloader, caching system and image processors separately as you need.
  • Prefetching images and showing them from cache to boost your app.
  • View extensions for UIImageView, NSImage, NSButton and UIButton to directly set an image from a URL.
  • Built-in transition animation when setting images.
  • Customizable placeholder and indicator while loading images.
  • Extensible image processing and image format easily.

Kingfisher 101

The simplest use-case is setting an image to an image view with the UIImageView extension:

let url = URL(string: "https://example.com/image.png")
imageView.kf.setImage(with: url)

Kingfisher will download the image from url, send it to both memory cache and disk cache, and display it in imageView. When you set with the same URL later, the image will be retrieved from cache and shown immediately.

A More Advanced Example

With the powerful options, you can do hard tasks with Kingfisher in a simple way. For example, the code below:

  1. Downloads a high-resolution image.
  2. Downsamples it to match the image view size.
  3. Makes it round cornered with a given radius.
  4. Shows a system indicator and a placeholder image while downloading.
  5. When prepared, it animates the small thumbnail image with a "fade in" effect.
  6. The original large image is also cached to disk for later use, to get rid of downloading it again in a detail view.
  7. A console log is printed when the task finishes, either for success or failure.

    let url = URL(string: "https://example.com/high_resolution_image.png")
    let processor = DownsamplingImageProcessor(size: imageView.size)
             >> RoundCornerImageProcessor(cornerRadius: 20)
    imageView.kf.indicatorType = .activity
    imageView.kf.setImage(
    with: url,
    placeholder: UIImage(named: "placeholderImage"),
    options: [
        .processor(processor),
        .scaleFactor(UIScreen.main.scale),
        .transition(.fade(1)),
        .cacheOriginalImage
    ])
    {
    result in
    switch result {
    case .success(let value):
        print("Task done for: \(value.source.url?.absoluteString ?? "")")
    case .failure(let error):
        print("Job failed: \(error.localizedDescription)")
    }
    }
    

It is really a very common situation I can meet in my daily work. Think about how many lines you need to write without Kingfisher. You will fall in love with it if you give it a try!

Learn More

To learn the using of Kingfisher by more examples, take a look at the Cheat Sheet. There we summarized most common tasks in Kingfisher, you can get a better idea on what this framework can do. There are also some tips for performance in the same page, remember to check them too.

Requirements

  • iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+
  • Swift 4.0+

Kingfisher 5.0 Migration - Kingfisher 5.x is NOT fully compatible with version 4.x. However, the migration is not difficult. Depending on your use cases, it may take no effect or several minutes to modify your existing code for the new version. Please follow the migration guide when you prepare to upgrade Kingfisher in your project.

If you are using an even earlier version, see the guides below to know the steps for migrating.

  • Kingfisher 4.0 Migration - Kingfisher 3.x should be source compatible to Kingfisher 4. The reason for a major update is that we need to specify the Swift version explicitly for Xcode. All deprecated methods in Kingfisher 3 has been removed, so please ensure you have no warning left before you migrate from Kingfisher 3 to Kingfisher 4. If you have any trouble in migrating, please open an issue to discuss.
  • Kingfisher 3.0 Migration - If you are upgrading to Kingfisher 3.x from an earlier version, please read this for more information.

Next Steps

We prepared a wiki page. You can find tons of useful things there.

  • Installation Guide - Follow it to integrate Kingfisher into your project.
  • Cheat Sheet- Curious about what Kingfisher could do and how would it look like when used in your project? See this page for useful code snippets. If you are already familiar with Kingfisher, you could also learn new tricks to improve the way you use Kingfisher!
  • API Reference - Lastly, please remember to read the full whenever you may need a more detailed reference.

Other

Future of Kingfisher

I want to keep Kingfisher lightweight. This framework will focus on providing a simple solution for downloading and caching images. This doesn’t mean the framework can’t be improved. Kingfisher is far from perfect, so necessary and useful updates will be made to make it better.

Developments and Tests

Any contributing and pull requests are warmly welcome. However, before you plan to implement some features or try to fix an uncertain issue, it is recommended to open a discussion first. It would be appreciated if your pull requests could build and with all tests green. :)

About the logo

The logo of Kingfisher is inspired by Tangram (七巧板), a dissection puzzle consisting of seven flat shapes from China. I believe she's a kingfisher bird instead of a swift, but someone insists that she is a pigeon. I guess I should give her a name. Hi, guys, do you have any suggestions?

Contact

Follow and contact me on Twitter or Sina Weibo. If you find an issue, just open a ticket. Pull requests are warmly welcome as well.

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! Your support is really important for the project and encourages us to continue. 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

Kingfisher is released under the MIT license. See LICENSE for details.