Position view bottom without using a spacer

前端 未结 3 1064
长发绾君心
长发绾君心 2020-12-19 19:40

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 bec

3条回答
  •  囚心锁ツ
    2020-12-19 20:08

    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.

提交回复
热议问题