<p align="center">
<img src="https://raw.githubusercontent.com/onevcat/Kingfisher/master/images/logo.png" alt="Kingfisher" title="Kingfisher" width="557"/>
</p>
<p align="center">
<a href="https://github.com/onevcat/Kingfisher/actions?query=workflow%3Abuild"><img src="https://github.com/onevcat/kingfisher/workflows/build/badge.svg?branch=master"></a>
<a href="https://swiftpackageindex.com/onevcat/Kingfisher/master/documentation/kingfisher"><img src="https://img.shields.io/badge/Swift-Doc-DE5C43.svg?style=flat"></a>
<a href="https://cocoapods.org/pods/Kingfisher"><img src="https://img.shields.io/cocoapods/v/Kingfisher.svg?style=flat"></a>
<a href="https://github.com/Carthage/Carthage/"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat"></a>
<a href="https://swift.org/package-manager/"><img src="https://img.shields.io/badge/SPM-supported-DE5C43.svg?style=flat"></a>
<br />
<a href="https://raw.githubusercontent.com/onevcat/Kingfisher/master/LICENSE"><img src="https://img.shields.io/cocoapods/l/Kingfisher.svg?style=flat"></a>
<a href="https://swiftpackageindex.com/onevcat/Kingfisher/master/documentation/kingfisher"><img src="https://img.shields.io/cocoapods/p/Kingfisher.svg?style=flat"></a>
</p>
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
- [x] Asynchronous image downloading and caching.
- [x] Loading image from either `URLSession`-based networking or local provided data.
- [x] Useful image processors and filters provided.
- [x] Multiple-layer hybrid cache for both memory and disk.
- [x] Fine control on cache behavior. Customizable expiration date and size limit.
- [x] Cancelable downloading and auto-reusing previous downloaded content to improve performance.
- [x] Independent components. Use the downloader, caching system, and image processors separately as you need.
- [x] Prefetching images and showing them from the cache to boost your app.
- [x] Extensions for `UIImageView`, `NSImageView`, `NSButton`, `UIButton`, `NSTextAttachment`, `WKInterfaceImage`, `TVMonogramView` and `CPListItem` to directly set an image from a URL.
- [x] Built-in transition animation when setting images.
- [x] Customizable placeholder and indicator while loading images.
- [x] Extensible image processing and image format easily.
- [x] Low Data Mode support.
- [x] SwiftUI support.
### Kingfisher 101
The simplest use-case is setting an image to an image view with the `UIImageView` extension:
```swift
import Kingfisher
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 it with the same URL later, the image will be retrieved from the cache and shown immediately.
It also works if you use SwiftUI:
```swift
var body: some View {
KFImage(URL(string: "https://example.com/image.png")!)
}
```
### 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.
```swift
let url = URL(string: "https://example.com/high_resolution_image.png")
let processor = DownsamplingImageProcessor(size: imageView.bounds.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 a common situation I can meet in my daily work. Think about how many lines you need to write without
Kingfisher!
### Method Chaining
If you are not a fan of the `kf` extension, you can also prefer to use the `KF` builder and chained the method
invocations. The code below is doing the same thing:
```swift
// Use `kf` extension
imageView.kf.setImage(
with: url,
placeholder: placeholderImage,
options: [
.processor(processor),
.loadDiskFileSynchronously,
.cacheOriginalImage,
.transition(.fade(0.25)),
.lowDataMode(.network(lowResolutionURL))
],
progressBlock: { receivedSize, totalSize in
// Progress updated
},
completionHandler: { result in
// Done
}
)
// Use `KF` builder
KF.url(url)
.placeholder(placeholderImage)
.setProcessor(processor)
.loadDiskFileSynchronously()
.cacheMemoryOnly()
.fade(duration: 0.25)
.lowDataModeSource(.network(lowResolutionURL))
.onProgress { receivedSize, totalSize in }
.onSuccess { result in }
.onFailure { error in }
.set(to: imageView)
```
And even better, if later you want to switch to SwiftUI, just change the `KF` above to `KFImage`, and you've done:
```swift
struct ContentView: View {
var body: some View {
KFImage.url(url)
.placeholder(placeholderImage)
.setProcessor(processor)
.loadDiskFileSynchronously()
.cacheMemoryOnly()
.fade(duration: 0.25)
.lowDataModeSource(.network(lowResolutionURL))
.onProgress { receivedSize, totalSize in }
.onSuccess { result in }
.onFailure { error in }
}
}
```
### Learn More
To learn the use of Kingfisher by more examples, take a look at the well-prepared [Cheat Sheet](https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet).
There we summarized the most common tasks in Kingfisher, you can get a better idea of what this framework can do.
There are also some performance tips, remember to check them too.
## Requirements
- iOS 12.0+ / macOS 10.14+ / tvOS 12.0+ / watchOS 5.0+ (if you use only UIKit/AppKit)
- iOS 14.0+ / macOS 11.0+ / tvOS 14.0+ / watchOS 7.0+ (if you use it in SwiftUI)
- Swift 5.0+
> If you need support from iOS 10 (UIKit/AppKit) or iOS 13 (SwiftUI), use Kingfisher version 6.x. But it won't work
> with Xcode 13.0 and Xcode 13.1 [#1802](https://github.com/onevcat/Kingfisher/issues/1802).
>
> If you need to use Xcode 13.0 and 13.1 but cannot upgrade to v7, use the `version6-xcode13` branch. However, you have to drop
> iOS 10 support due to another Xcode 13 bug.
>
> | UIKit | SwiftUI | Xcode | Kingfisher |
> |---|---|---|---|
> | iOS 10+ | iOS 13+ | 12 | ~> 6.3.1 |
> | iOS 11+ | iOS 13+ | 13 | `version6-xcode13` |
> | iOS 12+ | iOS 14+ | 13 | ~> 7.0 |
### Installation
A detailed guide for installation can be found in [Installation Guide](https://github.com/onevcat/Kingfisher/wiki/Installation-Guide).
#### Swift Package Manager
- File > Swift Packages > Add Package Dependency
- Add `https://github.com/onevcat/Kingfisher.git`
- Select "Up to Next Major" with "7.0.0"
#### CocoaPods
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'
use_frameworks!
target 'MyApp' do
pod 'Kingfisher', '~> 7.0'
end
```
#### Carthage
```
github "onevcat/Kingfisher" ~> 7.0
```
### Migrating
[Kingfisher 7.0 Migration](https://github.com/onevcat/Kingfisher/wiki/Kingfisher-7.0-Migration-Guide) - Kingfisher 7.x is NOT fully compatible with the previous version. However, c
没有合适的资源?快使用搜索试试~ 我知道了~
GASuspendViewDemo
共353个文件
swift:71个
sample:13个
plist:12个
需积分: 0 3 下载量 20 浏览量
2023-03-26
16:53:47
上传
评论
收藏 3.56MB ZIP 举报
温馨提示
一个添加在window上悬浮视图。 可固定,可拖动,还可以限制一个拖动范围。 可限定在只某些页面展示。
资源推荐
资源详情
资源评论
收起资源包目录
GASuspendViewDemo (353个子文件)
02635a857e87096eff2b4c880af86a1fc70df7 146B
02d4d32c702e4710a28cb713830244145d6a66 239B
03a6e46eb93e4d971d8078a0544a6264965e63 788B
042dffba0b67b9d6d4cd540d1bd295108eacff 2KB
069afd09fc689fd8cfae5dbd8c39bfff096d0c 155B
0978443f39dc66e8ef225d22e4d7df9c17cefb 267B
098f12065eec4546469050fd991bf55d068eb6 160B
0ece68cc51f6984dd9234db37b7759fb81b81f 2KB
106cef121f05097d44bafb853d5789f0a7ca80 10KB
10b741d61fb60b134b6efdfe19d7bd2a0ecac0 898B
136f0991c3e4cbf610c8aadb3aa60510860d9e 231B
13b58f06d618e19d51a8dcc1505ae81c6062ec 114B
13cbe54cf575af7cb63f8c18d6d21367a3583f 2KB
16300816773f2bf40e9f03402632a79296f5ea 4KB
16c6af6e16b34a3b96587ac6ab84e1e83c8120 108B
1d6d0be82772b1169e47d1b5b7f703b7203896 7KB
20d91cbcc6c2843fbbeb8b1aca28071ebb0f06 97B
2480f5ade8cbc792d51d9d615ba945601f8734 2KB
25eb232707201777cd15a438f01d1adcf91de8 2KB
2aea63b9cf1dd21e1fff0e848d97f3484ec2f1 8KB
2af28e803bc8c91dd75c14d968548b13a38565 1KB
2af7538517d891913220f2ddaf31451c0496b4 127B
2b8473f41476f820b4de253f9fbc4c9f1a215d 5KB
3023b8183f747e416f44195b3b97ecf316e85e 2KB
32619e4c9aa56e822446ab6f9b7b99c9b1842e 73B
32bd547278f1429e9e05e6701650aa6ec9b7fe 2KB
32c6111002ad9fdef487d2f10d99ac456b05ac 412KB
35449730e9772b4bab7a94196338eb08e3f416 427B
373fca024fe37a5c8e6c92a27d237f62faae0c 5KB
393f72ea2be603b50aca6839206cf0d3c0bcb6 17KB
3c19807cc9ae97c0b59a5b7f5eb7264349c462 67B
3cc9b8ba4e4ae5c6df5ed5e3f199668b7fead0 68B
3cf15c0dbe03fb029a2d5022e5924d6d6b8d4f 282B
3cf5bac252a1b0415df051443d847c5d1d75a7 59B
3d1f93bdfd1d71744d7976d358b64502dceece 256B
3d557d183791c4ac73b05d5fe1f88e89c8a835 3KB
3e3cae05768bb19ee69f24f4d78d12256989cc 82B
3f02899af19eab05f03d94700f8a3ef778b924 5KB
43265d9091ca06a7fb95b9c9532badf53b83cb 710B
43fe6e27dc60546f37eca17f97ed75802d224f 386B
45754b1e12559c1d23cfe60e0d9537bb3676b2 3KB
4a855d75526380dd2f92a160fa812c837ce5b9 2KB
4b386a46ce6dd09bc92a33256f88e7a19d46ef 2KB
4fca25033d0fa305c1a4922fbbfcc8f02db13c 95B
4feeb30b32f71763d9b48f2c4d7f2d8c5e9a43 3KB
53b2aa9f66fb1388fe31b603eacd1022581928 2KB
582fff354700dc16ee4016fddeb7f63cd981b0 3KB
586b5c15337e96feac3b0fdba7d454398472f1 4KB
591bf81bf4412908abcc5f50c8d26d8dff7eb2 390B
5b4bb5a3b5a70ebd2e3fe13dbb1226114b9b89 6KB
5cf78ddbba94cffe3d7a2a8b7493fae1029876 551B
5f4b7e0db6d47f6878b26520525899018ec947 204B
5f8e0987ee1bb017b10ccefe24816939bd4dbe 330B
6103803f67d01530c9fce50cd1c3457e676b27 127B
613e3ee1a9348462a11a77a619faa808a346eb 133B
622e41977c3b2874426b4f7ffd5f0941a1c20a 2KB
63214d4cd7283c25bd4cc2fce6ef11f56976f9 234B
634e7f7627f256295e65fe26563980ec51f1c0 292B
64852600e063206a7b3d1068003ff0b8cc93ec 108B
6601c05141ca4a7dea2d0d733f8bea7e30fa31 450B
67376ebacb410fd873cac1d8d8dd431b262c02 165B
68958195b47ae577b1ba6679d18d2242bbf992 437B
689729ba15772ff261dcd5afc37203cd473b9e 1KB
69317592510f0305c41d1c71d1ed864f34005d 253B
69b1b2ddc915e057799e76159eb6e740e0df3e 485KB
6b2017c11542995b0b593a849dcee45744cad4 3KB
6b5d4659408dbe35f748b20edf26305a8d8057 135B
6bd324c26d854187559f27f8194c8afd1795ac 58B
6ca015fefd327948c27514f5f368025244fe33 22KB
6ed459e8870143cdeefb575b9b85eb32083260 16KB
6f7c62ee835d05284c3eec390ea8d6d2c509f7 213B
6fb32437fdc6bc5c86fee724fb8e11ba369eac 538B
7076ba3307ea54536a8e85b8aebec8e6b61c64 119B
71d4ad34ccdc8354c213399debf3369a573c7b 102B
7359386b4020c20f7593ac7bd95f8de8441a3f 9KB
75e2af030926dd2b18bf6b8a95f6b91bc0284a 1KB
75f0eb89f3c26e57b271b8042c35202e6914ea 2KB
77c0138df7540e54986e86bd9b86f1379ab081 250B
781d54b3dc937793dd57db9e2d4814405bb6a5 120B
78f192a0605a066143bf29f8b51e71045a5e8e 5KB
798a9f475beaac3a750f52822e7cd14c025c0a 9KB
7d03ef3e10cc2d55bdae185ca3911afef604b4 127B
7e756214a2f7b2bfda6d762fd42ee20bac87e2 108B
7e8884a62c80a823fc6f8adff295ae4f5c5ca4 59B
7e92fe75d40d523a253450583ad383e1c0ebe1 201B
7ecd18acb7c4dee97b6e925ba703806217e6c9 944B
807e1431753346233c39ebe466e4b4ef919175 119B
8143347cb8b429ccf0d97362541e2deeaade7d 71B
818e2a8894f74578ca6dbb2e362abaef46f41a 882B
81c53fce7ea85ca745e969e46cae05c40deaff 435B
8443c6a2c946487fc2ea419d15255950e1bc6b 1KB
84eda2e694d1c496e7b9b9834ba64614bf56f4 309B
8513a8a7910ee82bddd8f543502403cca42dca 136B
8552003607aa19b914ed198a8b30dc51e5ceef 70B
865e0f0ad1b66f55f3c3b226d52d2868bf6937 70B
8789700816459c1e1480e0b34781d9fb78a1ca 105B
87986d3311dd9b5f4c34474ccbce643b47da7e 51B
888ba58e6c62ab6b957c867b5e55ce685f2ed5 659B
89cb6a0cdec2cb99607f72453f0f5e7b98da8a 94B
89d0ed69dcd9cf44f32e6b6d6ce1830a503541 106B
共 353 条
- 1
- 2
- 3
- 4
资源评论
风浅月明
- 粉丝: 877
- 资源: 152
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功