title: How to animate @State value that is passed through a custom struct in SwiftUI
body: <p>I'm currently making the authentication view for my app, and I want to add some movement. I decided that using animation to change the custom corner radius of my view would do the trick.</p>
  <p>I've attached a link below of what it looks like currently.</p>
  <p><a href="https://i.stack.imgur.com/qQ4OO.png" rel="nofollow noreferrer">https://i.stack.imgur.com/qQ4OO.png</a></p>
  <p>Here is the code that specifically handles the corner radius (using a custom struct to only affect that corner):</p>
  <pre><code>Color(&quot;lapiz&quot;).ignoresSafeArea()
                          .customCornerRadius(CGSize(width: 125, height: 125), corners: .bottomRight)
  </code></pre>
  <p>Of course, there's more code than that, but that's what deals with making the corner radius. Here is the <code>.customCornerRadius</code> extension code and struct:</p>
  <pre><code>public extension View {
      
      func customCornerRadius(_ radius: CGSize, corners: UIRectCorner) -&gt; some View {
          clipShape( CustomRoundedCorner(size: radius, corners: corners) )
      }
  }
  </code></pre>
  <pre><code>struct CustomRoundedCorner: Shape {
      
      var size: CGSize
      var corners: UIRectCorner
      
      func path(in rect: CGRect) -&gt; Path {
          let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: size)
          return Path(path.cgPath)
      }
  }
  </code></pre>
  <p>The <code>CGSize</code> width and height passed into the <code>.customCornerRadius</code> is currently set to 125. Say I attached this to a @State variable.</p>
  <p>How would I animate the view to switch between, for example, a <code>CGSize</code> of 100? Could I have this repeat indefinitely, back and forth?</p>
  <p>Thanks in advance.</p>