How can I animate a sequence of images (say Frame-1.png all the to Frame-6) using the SwiftUI framework?
I've tried creating an array of "images". Then I assigned the UIImage.animatedImage(with: images, duration: 1.0) method to a variable called "animatedImage" finally I tried Image(uiImage: animatedImage) in "body" of "ContentView.swift"
var images: [UIImage]! = [UIImage(named: "Sequence/frame-1")!,
UIImage(named: "Sequence/frame-2")!,
UIImage(named: "Sequence/frame-3")!,
UIImage(named: "Sequence/frame-4")!,
UIImage(named: "Sequence/frame-5")!,
UIImage(named: "Sequence/frame-6")!
]
let animatedImage : UIImage! = UIImage.animatedImage(with: images, duration: 1.0)
//////Then in the ContentView.swift I've tried this code:
struct ContentView : View {
var body: some View {
Image(uiImage: animatedImage)
}
}
when I run the program it just shows the firs frame, but I expected an animation of the frames