Wie bewege ich den Boden im Swiftui Food Card -Design nach unten?
Posted: 11 Feb 2025, 07:06
Ich erstelle eine Lebensmittelkarte in Swiftui, aber ich habe ein Problem mit der Elementpositionierung. Ich brauche den unteren HStack (mit Kalorien und einem Herzsymbol), um mit dem Boden der Karte ausgerichtet zu werden, aber im Moment ist es höher als erwartet. HStack Down so, dass es am unteren Rand der Karte platziert ist, wenn man bedenkt, dass der VStack bereits ein Bild, einen Namen und eine Beschreibung enthält? > vstack (Ausrichtung: .Leading) {
text (name)
.font(.title3)
170) < /p>
}
text (name)
.font(.title3)
170) < /p>
Code: Select all
Text(description)
.font(.caption)
HStack(spacing: 84) {
Text("\(calories) Kcal")
.font(.body)
.fontWeight(.semibold)
Image(systemName: "heart.fill")
.font(.title)
.fontWeight(.semibold)
.foregroundStyle(.my)
}
}
.frame(maxWidth: 227, maxHeight: 349)
.background(.red)
.clipShape(
.rect(
topLeadingRadius: 120,
bottomLeadingRadius: 30,
bottomTrailingRadius: 30,
topTrailingRadius: 120
)
)
.shadow(color: .black.opacity(0.1), radius: 10, y: 4)
.overlay {
Image(.saladAllotment)
.resizable()
.scaledToFit()
.frame(maxWidth: 227)
.padding(.top, -140)
.shadow(color: .black.opacity(0.3), radius: 10, y: 4)
}