Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yutailang0119/sbpasyncimage
Backport of SwiftUI.AsyncImage to iOS 14, macOS 11, tvOS 14 and watchOS 7 and earlier.
https://github.com/yutailang0119/sbpasyncimage
swift swiftui
Last synced: 3 months ago
JSON representation
Backport of SwiftUI.AsyncImage to iOS 14, macOS 11, tvOS 14 and watchOS 7 and earlier.
- Host: GitHub
- URL: https://github.com/yutailang0119/sbpasyncimage
- Owner: yutailang0119
- License: mit
- Created: 2021-07-02T18:31:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-06T13:40:34.000Z (over 2 years ago)
- Last Synced: 2024-05-01T15:44:37.148Z (9 months ago)
- Topics: swift, swiftui
- Language: Swift
- Homepage:
- Size: 36.1 KB
- Stars: 51
- Watchers: 4
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SBPAsyncImage
Backport of [SwiftUI.AsyncImage](https://developer.apple.com/documentation/swiftui/asyncimage) to iOS 14, macOS 11, tvOS 14 and watchOS 7 and earlier.
AsyncImage is a view that asynchronously loads and displays an image.
However, AsyncImage is available from iOS 15, macOS 12, tvOS 15, and watchOS 8.
SBPAsyncImage provides interface and behavior of AsyncImage to earlier OS.## A Work In Progress
SBPAsyncImage is still in active development.
Please file all bugs, issues, and suggestions as an Issue in the GitHub repository.## Installation
### [Swift Package Manager](https://swift.org/package-manager/)
```swift
// swift-tools-version:5.4
// The swift-tools-version declares the minimum version of Swift required to build this package.import PackageDescription
let package = Package(
name: "SBPAsyncImageExample",
platforms: [
.iOS(.v13),
.macOS(.v10_15),
.tvOS(.v13),
.watchOS(.v6),
],
dependencies: [
.package(url: "https://github.com/yutailang0119/SBPAsyncImage", .exact("0.1.0")),
],
targets: [
.target(
name: "SBPAsyncImageExample",
dependencies: ["SBPAsyncImage"]),
]
)
```## Usage
```swift
import SwiftUI
import SBPAsyncImagestruct ContentView: View {
var body: some View {
BackportAsyncImage(url: URL(string: "https://example.com/icon.png"))
.frame(width: 200, height: 200)
}
}
```### Custom placeholder
```swift
import SwiftUI
import SBPAsyncImagestruct ContentView: View {
var body: some View {
BackportAsyncImage(url: URL(string: "https://example.com/icon.png")) { image in
image.resizable()
} placeholder: {
ProgressView()
}
.frame(width: 50, height: 50)
}
}
```## Author
[Yutaro Muta](https://github.com/yutailang0119)
- [email protected]
- [@yutailang0119](https://twitter.com/yutailang0119)## License
The project is available under [MIT Licence](./LICENSE)