title: How to animate images in SwiftUI, to play a frame animation
body: <p>I want to animate images in SwiftUI's Image view</p>
  
  <p>First, I tried creating some variables and a function to toggle the Image("imageVariable"). It changes but there is no animation even tried the <code>withAnimation { }</code> method </p>
  
  <p>Secondly, I tried to use a UIKit view. Here, the animation works but I can't apply the <code>resizable()</code> modifier or a set a fixed frame</p>
  
  <pre><code>var images: [UIImage]! = [UIImage(named: "pushup001")!, UIImage(named: "pushup002")!]
  
  let animatedImage = UIImage.animatedImage(with: images, duration: 0.5)
  
  struct workoutAnimation: UIViewRepresentable {
  
      func makeUIView(context: Self.Context) -&gt; UIImageView {
          return UIImageView(image: animatedImage)
      }
  
      func updateUIView(_ uiView: UIImageView, context: UIViewRepresentableContext&lt;workoutAnimation&gt;) {
  
      }
  }
  
  
  struct WorkoutView: View {
      var body: some View {
          VStack {
              workoutAnimation().aspectRatio(contentMode: .fit)
          }
      }
  }
  </code></pre>
  
  <p>In method 1 I can change the image but not animate, while, in method 2 I can animate but not control it's size</p>