# SDWebImageSwiftUI
[![CI Status](https://travis-ci.org/SDWebImage/SDWebImageSwiftUI.svg?branch=master)](https://travis-ci.org/SDWebImage/SDWebImageSwiftUI)
[![Version](https://img.shields.io/cocoapods/v/SDWebImageSwiftUI.svg)](https://cocoapods.org/pods/SDWebImageSwiftUI)
[![License](https://img.shields.io/cocoapods/l/SDWebImageSwiftUI.svg)](https://cocoapods.org/pods/SDWebImageSwiftUI)
[![Platform](https://img.shields.io/cocoapods/p/SDWebImageSwiftUI.svg)](https://cocoapods.org/pods/SDWebImageSwiftUI)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)](https://github.com/Carthage/Carthage)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg)](https://swift.org/package-manager/)
[![codecov](https://codecov.io/gh/SDWebImage/SDWebImageSwiftUI/branch/master/graph/badge.svg)](https://codecov.io/gh/SDWebImage/SDWebImageSwiftUI)
## What's for
SDWebImageSwiftUI is a SwiftUI image loading framework, which based on [SDWebImage](https://github.com/SDWebImage/SDWebImage).
It brings all your favorite features from SDWebImage, like async image loading, memory/disk caching, animated image playback and performances.
The framework provide the different View structs, which API match the SwiftUI framework guideline. If you're familiar with `Image`, you'll find it easy to use `WebImage` and `AnimatedImage`.
## Features
Since SDWebImageSwiftUI is built on top of SDWebImage, it provide both the out-of-box features as well as advanced powerful features you may want in real world Apps. Check our [Wiki](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage) when you need:
- [x] Animated Image full-stack solution, with balance of CPU && RAM
- [x] Progressive image loading, with animation support
- [x] Reusable download, never request single URL twice
- [x] URL Request / Response Modifier, provide custom HTTP Header
- [x] Image Transformer, apply corner radius or CIFilter
- [x] Multiple caches system, query from different source
- [x] Multiple loaders system, load from different resource
You can also get all benefits from the existing community around with SDWebImage. You can have massive image format support (GIF/APNG/WebP/HEIF/AVIF/SVG/PDF) via [Coder Plugins](https://github.com/SDWebImage/SDWebImage/wiki/Coder-Plugin-List), PhotoKit support via [SDWebImagePhotosPlugin](https://github.com/SDWebImage/SDWebImagePhotosPlugin), Firebase integration via [FirebaseUI](https://github.com/firebase/FirebaseUI-iOS), etc.
Besides all these features, we do optimization for SwiftUI, like Binding, View Modifier, using the same design pattern to become a good SwiftUI citizen.
## Version
This framework is under heavily development, it's recommended to use [the latest release](https://github.com/SDWebImage/SDWebImageSwiftUI/releases) as much as possible (including SDWebImage dependency).
This framework follows [Semantic Versioning](https://semver.org/). Each source-break API changes will bump to a major version.
## Changelog
This project use [keep a changelog](https://keepachangelog.com/en/1.0.0/) format to record the changes. Check the [CHANGELOG.md](https://github.com/SDWebImage/SDWebImageSwiftUI/blob/master/CHANGELOG.md) about the changes between versions. The changes will also be updated in Release page.
## Contribution
All issue reports, feature requests, contributions, and GitHub stars are welcomed. Hope for active feedback and promotion if you find this framework useful.
## Requirements
+ Xcode 12+
+ iOS 13+
+ macOS 10.15+
+ tvOS 13+
+ watchOS 6+
+ Swift 5.2+
## SwiftUI 2.0 Compatibility
iOS 14(macOS 11) introduce the SwiftUI 2.0, which keep the most API compatible, but changes many internal behaviors, which breaks the SDWebImageSwiftUI's function.
From v2.0.0, we adopt SwiftUI 2.0 and iOS 14(macOS 11)'s behavior. You can use `WebImage` and `AnimatedImage` inside the new `LazyVStack`.
```swift
var body: some View {
ScrollView {
LazyVStack {
ForEach(urls, id: \.self) { url in
AnimatedImage(url: url)
}
}
}
}
```
Note: However, many differences behavior between iOS 13/14's is hard to fixup. Due to maintain issue, in the future release, we will drop the iOS 13 supports and always match SwiftUI 2.0's behavior.
## Installation
#### Swift Package Manager
SDWebImageSwiftUI is available through [Swift Package Manager](https://swift.org/package-manager/).
+ For App integration
For App integration, you should using Xcode 12 or higher, to add this package to your App target. To do this, check [Adding Package Dependencies to Your App](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app?language=objc) about the step by step tutorial using Xcode.
+ For downstream framework
For downstream framework author, you should create a `Package.swift` file into your git repo, then add the following line to mark your framework dependent our SDWebImageSwiftUI.
```swift
let package = Package(
dependencies: [
.package(url: "https://github.com/SDWebImage/SDWebImageSwiftUI.git", from: "2.0.0")
],
)
```
#### CocoaPods
SDWebImageSwiftUI is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'SDWebImageSwiftUI'
```
#### Carthage
SDWebImageSwiftUI is available through [Carthage](https://github.com/Carthage/Carthage).
```
github "SDWebImage/SDWebImageSwiftUI"
```
## Usage
### Using `WebImage` to load network image
- [x] Supports placeholder and detail options control for image loading as SDWebImage
- [x] Supports progressive image loading (like baseline)
- [x] Supports success/failure/progress changes event for custom handling
- [x] Supports indicator with activity/progress indicator and customization
- [x] Supports built-in animation and transition, powered by SwiftUI
- [x] Supports animated image as well!
```swift
var body: some View {
WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"))
// Supports options and context, like `.delayPlaceholder` to show placeholder only when error
.onSuccess { image, data, cacheType in
// Success
// Note: Data exist only when queried from disk cache or network. Use `.queryMemoryData` if you really need data
}
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
.placeholder(Image(systemName: "photo")) // Placeholder Image
// Supports ViewBuilder as well
.placeholder {
Rectangle().foregroundColor(.gray)
}
.indicator(.activity) // Activity Indicator
.transition(.fade(duration: 0.5)) // Fade Transition with duration
.scaledToFit()
.frame(width: 300, height: 300, alignment: .center)
}
```
Note: This `WebImage` using `Image` for internal implementation, which is the best compatible for SwiftUI layout and animation system. But unlike SwiftUI's `Image` which does not support animated image or vector image, `WebImage` supports animated image as well (by defaults from v2.0.0).
However, The `WebImage` animation provide simple common use case, so it's still recommend to use `AnimatedImage` for advanced controls like progressive animation rendering, or vector image rendering.
```swift
@State var isAnimating: Bool = true
var body: some View {
WebImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"), isAnimating: $isAnimating)) // Animation Control, supports dynamic changes
// The initial value of binding should be true
.customLoopCount(1) // Custom loop count
.playbackRate(2.0) // Playback speed rate
.playbackMode(.bounce) // Playback normally to the end, then reversely back to the start
// `WebImage` supports advanced control just like `AnimatedImage`, but without the progressive animation support
}
```
No
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
简易博客系统,含客户端和服务器端,采用各种编程语言实现. 覆盖语言:Java、Kotlin、Dart、Go、JavaScript(JS)、TypeScript(TS)、ArkTS、Swift、PHP。 覆盖平台:安卓(Java、Kotlin)、iOS(SwiftUI)、Fl…. 软件开发设计:PHP、QT、应用软件开发、系统软件开发、移动应用开发、网站开发C++、Java、python、web、C#等语言的项目开发与学习资料 硬件与设备:单片机、EDA、proteus、RTOS、包括计算机硬件、服务器、网络设备、存储设备、移动设备等 操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络与通信是一个非常广泛的领域,它涉及到计算机科学、电子工程、数学等多个学科的知识。 云计算与大数据:数据集、包括云计算平台、大数据分析、人工智能、机器学习等,云计算是一种基于互联网的计算方式,通过这种方式,共享的软硬件资源和信息可以按需提供给计算机和其他设备。
资源推荐
资源详情
资源评论
收起资源包目录
简易博客系统,含客户端和服务器端,采用各种编程语言实现. .zip (894个子文件)
lblbc_blog.apk 5.58MB
gradlew.bat 3KB
mvnw.cmd 6KB
mysql.cnf 345B
login.dart 3KB
http_manager.dart 3KB
blog_list.dart 3KB
edit_blog.dart 3KB
add_blog.dart 2KB
home.dart 2KB
mine.dart 1KB
widget_test.dart 1KB
token_interceptor.dart 790B
user_bean.dart 606B
main.dart 580B
constants.dart 467B
request_api.dart 263B
lblbc_blog.db 16KB
lblbc_blog.db 12KB
DebugProfile.entitlements 348B
Release.entitlements 240B
.env 337B
.env 84B
HttpUtil.ets 4KB
EditBlog.ets 2KB
UserDataStore.ets 2KB
Login.ets 2KB
Ability.test.ets 2KB
AddBlog.ets 2KB
BlogList.ets 2KB
index.ets 910B
app.ets 893B
Blog.ets 660B
app.ets 364B
Constants.ets 277B
List.test.ets 97B
.gitignore 732B
.gitignore 569B
.gitignore 400B
.gitignore 285B
.gitignore 225B
.gitignore 147B
.gitignore 98B
.gitignore 89B
.gitignore 47B
.gitignore 47B
.gitignore 39B
.gitignore 39B
.gitignore 36B
.gitignore 29B
.gitignore 26B
.gitignore 16B
.gitignore 13B
.gitignore 13B
.gitignore 13B
.gitignore 6B
.gitignore 6B
.gitignore 4B
blog_c.go 4KB
user_c.go 4KB
jwt_s.go 3KB
user_repository.go 2KB
auth_c.go 2KB
auth_s.go 2KB
main.go 2KB
blog_s.go 2KB
user_s.go 2KB
blog_repository.go 1KB
database.go 1KB
jwt_auth.go 1KB
user.go 859B
blog_dto.go 735B
blog.go 704B
response.go 438B
user_dto.go 433B
register_dto.go 413B
login_dto.go 388B
build.gradle 2KB
build.gradle 2KB
build.gradle 576B
settings.gradle 462B
settings.gradle 364B
build.gradle 296B
gradlew 6KB
SDmetamacros.h 30KB
SDWebImageDefine.h 22KB
SDImageCache.h 21KB
UIButton+WebCache.h 20KB
NSButton+WebCache.h 17KB
SDWebImageDownloader.h 15KB
SDImageCoder.h 14KB
SDWebImageManager.h 13KB
SDImageLoader.h 10KB
UIImageView+WebCache.h 9KB
SDAnimatedImageView+WebCache.h 8KB
SDWebImageDownloaderOperation.h 8KB
SDImageTransformer.h 8KB
SDImageCacheDefine.h 8KB
SDWebImageTransition.h 7KB
SDAnimatedImage.h 6KB
共 894 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
妄北y
- 粉丝: 9805
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功