HStack とグリッドをネストする VStack を使用してビューを作成しようとしています ( https://github.com/spacenation/swiftui-grid )。期待される結果は、HStack とすべてのグリッド アイテムがレンダリングされることです。実際の結果は、グリッドの 1 つの項目のみがレンダリングされることです。しかし、HStack を VStack に変更すると、ビューは期待どおりにレンダリングされます。Pls は、グリッドが ZStack をネストする Geometry Reader をレンダリングすることに注意してください。これが私のコードと画像です。画像の青枠がグリッドです。高さが縮みました。
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)