High-performance animation image library.
let package = Package(
dependencies: [
.package(url: "https://github.com/noppefoxwolf/AnimatedImage", from: "0.0.x")
],
)
AnimatedImage pre-decodes and caches all animation frames. Optimize the number of drawing frames from the drawing size and drawing timestamp to prevent the cache size from becoming too large. It is designed so that all processing does not depend on the MainActor.
let imageView = AnimatedImage(frame: .null)
let image = APNGImage(data: data)
imageView.image = image
imageView.startAnimating()
@State var image = GIFImage(data: data)
var body: some View {
AnimatedImagePlayer(image: image)
}
public final class ManualAnimatedImage: AnimatedImage {
public let name: String
let images: [CGImage]
public init(name: String = UUID().uuidString, images: [CGImage]) {
self.name = name
self.images = images
}
public nonisolated func makeImageCount() -> Int {
images.count
}
public nonisolated func makeDelayTime(at index: Int) -> Double {
0.1
}
public nonisolated func makeImage(at index: Int) -> CGImage? {
images[index]
}
}
- Swift 6.0
- iOS 16
AnimatedImage is available under the MIT license. See the LICENSE file for more info.