title: How to animate/transition text value change in SwiftUI
body: <p>I am trying to animate value change in a text using <code>withAnimation</code> but it doesn't seem to work. I have come across a similar question but the <a href="https://stackoverflow.com/a/57860336/4366237">answer</a> is not animating the text value.</p>
  <p>I am trying to recreate this behaviour in pure SwiftUI
  (<a href="https://stackoverflow.com/a/16367409/4366237">UIKit Example</a>):</p>
  <p><a href="https://i.stack.imgur.com/Y8uaD.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/Y8uaD.gif" alt="enter image description here" /></a></p>
  <p>I have tried this code but it doesn't animate the text change:</p>
  <pre><code>struct TextAnimationView: View {
      @State private var textValue = &quot;0&quot;
      var body: some View {
          VStack (spacing: 50) {
              Text(textValue)
                  .font(.largeTitle)
                  .frame(width: 200, height: 200)
                  .transition(.opacity)
              Button(&quot;Next&quot;) {
                  withAnimation (.easeInOut(duration: 1)) {
                      self.textValue = &quot;\(Int.random(in: 1...100))&quot;
                  }
              }
          }
      }
  }
  </code></pre>
  <p>I have a very little experience with SwiftUI, is there another way to achieve this?</p>
  <p>Thanks in advance :)</p>