title: SwiftUI Animate Image on Button
body: <p>Using SwiftUI, I'm trying to show an animated image and hide the text when the user clicks the button.  Here is my code:</p>
  
  <pre><code>@State private var showingActivity = false
  
  var body: some View {
      Button(action: {
          self.showingActivity.toggle()
      }) { 
          HStack {
              if self.showingActivity {
                  Image(systemName: "arrow.2.circlepath")
                      .font(.system(size: 29))
                      .rotationEffect(.degrees(self.showingActivity ? 360.0 : 0.0))
                      .animation(Animation.linear(duration: 1.5).repeatForever(autoreverses: false))
              }
              else {
                  Text("Continue")
              }
          }
      }
  }
  </code></pre>
  
  <p>The <strong>Continue</strong> text appears and when clicked it disappears (as expected) and the image shows, but no animation.  Any ideas what I might be doing wrong.</p>
  
  <p>Thanks</p>