title: How to figure out the width of a string dynamically in SwiftUI
body: <p>Let's say I have a text called: <code>This</code>. I want to figure out the width of the text called <code>This</code> so that I can assign a width to another view's frame. How do I go about it?</p>
  
  <pre><code>struct BadgeTextView: View {
  
  var text: String
  
  var body: some View {
      Rectangle()
          .fill(Color.red)
      .cornerRadius(3)
          .frame(width: text.???, height: &lt;#T##CGFloat?#&gt;, alignment: &lt;#T##Alignment#&gt;)
  
  }
  }  
  </code></pre>