I’ve attached an image showing what I want. The red circle in the example below represents the image:
The image (red circle) must be vertically centered in its container. How can I make the text horizontally centered and below the image? If I use a VStack, the VStack will be centered and not the image — the image will move up. I do not know the size of the image.
3
Answers
You can use offset to set the text after circle .The following code may help you:
I’m not really sure what you really trying to achieve here, but if you just want the text to be centred under the image, this should sort out your problem. However, if the text goes multiple lines, the
y
position of the text will move up, unless everything is fixed or the text font scaled down in a single line.This is a great use of an overlay combined with an alignment guide.
Notice how this is a simple and scaleable solution that doesn’t require any fancy code but a single alignment guide.