GIFImage is a Swift package that provides easy integration of GIFs into SwiftUI applications. It extends UIImage
to handle GIFs and includes a UIViewRepresentable
struct to integrate with SwiftUI's view system.
- Load and display GIF images in SwiftUI views.
- Supports all iOS devices running iOS 13 or later.
- iOS 13.0+
- Swift 5.3+
- Xcode 12.0+
You can install GIFImage using the Swift Package Manager by adding it as a dependency to your project's Package.swift
file:
- Open your Xcode project.
- Click on "File" > "Swift Packages" > "Add Package Dependency..."
- Enter the package repository URL:
https://github.com/benjaminsage/GIFImage
- Specify the version you want to use. You can select a specific version, a branch, or a commit.
- Click "Next" and Xcode will download the package and add it to your project.
Alternatively, you can manually add the package to your Package.swift
file. Here's an example:
dependencies: [
.package(url: "https://github.com/benjaminsage/GIFImage", .upToNextMajor(from: "1.0.0"))
]
To use GIFImage, import it at the top of your Swift file:
import SwiftUI
import GIFImage
To display a GIF, simply create a GIFImage
view and pass the name of your GIF file:
GIFImage(imageName: "exampleGif")
Ensure that your GIF file is added to your Xcode project and is included in the target.
Work in progress.
Here is a simple example of how to use GIFImage in a SwiftUI view:
struct ContentView: View {
var body: some View {
GIFImage(imageName: "yourGifFileName")
}
}
Replace "yourGifFileName"
with the name of your GIF file, minus the '.gif' extension.
GIFImage is available under the MIT license. See the LICENSE file for more info.