0

I have such case

VStack(alignment: .center) { 

  HStack { 
     Text("Title text")
     if shouldDisplayImage {
        Image(systemName: "dot")
     }
  }

  Text("Description text")
}

But I want to have both texts in VStack centered horizontally and image that is sometimes displayed and sometimes hidden to be next to title text

Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143

1 Answers1

1

enter image description here

As Asperi suggested we can use .overlay() on Spacer()

Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143