首页 > 解决方案 > 使用 SwiftUI 等高子视图

问题描述

等于 Image(方形)和 TextOne 的高度,带有填充。没有 GeometryReader 怎么办?

我不能使用 GeometryReader 因为我将此视图用作列表行

var body: some View {
    return HStack {

        VStack {

            Image(systemName: "name").resizable().frame(width: ???, height: ???)

            Spacer()
        }

        VStack {
            HStack (alignment: .center) {

                Text("TextOne").padding()

                Spacer()

                Text("TextTwo").padding()
            }

            HStack (alignment: .top) {


                Text("TextDownOne").padding()

                Spacer()

                Button(action: { action() }) {
                    Text("ButtonText").padding()
                }
            }
        }
    }
}

标签: swiftuiheightequals

解决方案


推荐阅读