title: SwiftUI: Center Content in ScrollView
body: <p>I'm trying to center a bunch of views in a <code>VStack</code> within a <code>ScrollView</code> in SwiftUI. To simplify things, I'm just trying to get it to work with a single <code>Text</code> view. Here's what I've come up with so far:</p>
  <pre><code>var body: some View {
    ScrollView(alwaysBounceVertical: true){
      HStack(alignment: .center) {
        Spacer()
        Text(&quot;This Is a Test&quot;)
        Spacer()
      } //HStack
      .background(Color.green)
    } //ScrollView
    .background(Color.gray)
  }
  </code></pre>
  <p>This results in this:</p>
  <p><a href="https://i.stack.imgur.com/TTjMK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TTjMK.png" alt="enter image description here" /></a></p>
  <p>I want the text to be in the middle like this:</p>
  <p><a href="https://i.stack.imgur.com/fI76n.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fI76n.png" alt="enter image description here" /></a></p>
  <p>So the <code>HStack</code> should be full-width and the <code>Text</code> should be centered within it. It seems like this should be easy, but I don't get what I'm doing wrong. :)</p>