How to position child views within a parent view

Please apologize if this question is really trival. I implementent a content view with two buttons on it. One button should be 8px below the top, the other 8px above the bottom. Maybe I am doing something wrong. But I would use a simple ZStack here. Only problem is that I can set only one alignment for the ZStack at a time. So I can either align all views from the top border or from the bottom border but not one from the top and one from the bottom. Is there a way to solve this layout problem with these three views and a ZStack?

Answered by Claude31 in 416265022

That's the purpose of geometryReader.


To get the basics:

h ttps://swiftui-lab.com/geometryreader-to-the-rescue/

Is it possible to show us a drawing/screenshot of what you want? - maybe some code too?

Accepted Answer

That's the purpose of geometryReader.


To get the basics:

h ttps://swiftui-lab.com/geometryreader-to-the-rescue/

Thank you, thats exactly what I need.

How to position child views within a parent view
 
 
Q