我正在尝试使用嵌套 HStack 和网格(https://github.com/spacenation/swiftui-grid)的 VStack 来组成视图。预期的结果是 HStack 和所有网格项都应该呈现。实际结果是只有一项网格呈现。但是当我将 HStack 更改为 VStack 时,视图按预期呈现。请注意,网格呈现了一个几何阅读器,它嵌套了一个 ZStack 这是我的代码和图像。图像中的蓝框是网格。它的高度缩小了。
ScrollView {
VStack(spacing: 0) {
HStack {
ImageView(urlString: featuredItem.imageUrl, id: featuredItem.id)
VStack( alignment: .leading, spacing: 0) {
Text(featuredItem.title)
.padding(.vertical, 16)
.font(.custom("AbrilFatface-Regular", size: 48))
.fixedSize(horizontal: false, vertical: true)
Rectangle()
.fill(Color.red)
.frame(width: 96, height: 8)
Text(featuredItem.quote)
.font(.custom("Rubik-Regular", size: 14))
.padding(.top, 16)
.padding(.bottom, 32)
HStack {
ImageView(urlString: featuredItem.storeAvatarUrl, id:
featuredItem.id, width: 32, height: 32, isClipped: true)
Text(featuredItem.storeName)
.font(.custom("Rubik-Medium", size: 14))
}
}
.frame(width: 246)
}
.overlay(
GeometryReader { proxy in
VStack {
Text(self.featuredItem.price)
.frame(width: 72, height: 48)
}
.frame(width: proxy.size.width, height: proxy.size.height,
alignment: .topTrailing)
}
)
ShrineGrid(columns: 2, rowsHeight: .fixed(250))
}
}.edgesIgnoringSafeArea(.all)