Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Position view bottom without using a spacer

Tags:

How can I position a View at the bottom without using a spacer. I know I can achieve it placing a spacer and my view in inside a VStack but I don't want to use a spacer because I don't want my view to take up all the vertical space. With UIKit I would position it at safe area bottom guide.

like image 787
Peter Warbo Avatar asked Dec 03 '19 20:12

Peter Warbo


1 Answers

I think the simplest way is to add a frame for the container view.

Group{ // container View
    Text("iner label")
}.frame(maxHeight: .infinity, alignment: .bottom)

If you don't add frame, the default frame will wrap the inner view and has the same size as the inner View. If you add a frame, it will create a space belonging to the outer view, in the UIView concept, it's a superView. Then you will see what you will need to handle.

like image 101
E.Coms Avatar answered Nov 15 '22 04:11

E.Coms