ios - SwiftUI 将 vstack 推送到屏幕的剩余长度
问题描述
我目前有一个产品页面视图,但我遇到了一些问题。我的目标是将灰褐色推到屏幕底部。我尝试过使用 Spacer(),并在其中包含 Spacer() 的 VStack 下添加一个 VStack,但它没有推到屏幕底部。我怎样才能做到这一点?
ZStack {
Color.white
ScrollView {
VStack {
KFImage(URL(string: bottle?.image ?? "Test"))
.resizable()
.frame(width: 200, height: 300)
.padding([.top], 50)
}
.padding([.bottom], 40)
VStack(alignment: .leading) {
HStack {
Text(bottle?.name ?? "Test")
.font(.title2)
.fontWeight(.semibold)
Spacer()
SpiritTag(spirit: bottle?.varietal ?? "Other")
}
if((bottle?.brand_id) != nil) {
NavigationLink(destination: BrandView(brandId: bottle?.brand_id ?? "1")) {
HStack {
KFImage(URL(string: brand?.logo ?? "Test"))
.resizable()
.frame(width: 48, height: 48)
.cornerRadius(10)
VStack(alignment: .leading) {
Text("\(brand?.name ?? "Unknown")")
.fontWeight(.bold)
Text("\(brand?.bottle_count ?? 0) bottles")
.font(.caption)
}
}
}
}
HStack {
Button(action: {
self.show_modal = true
}) {
Text("Add to list")
}
.frame(height: 15)
.frame(maxWidth: .infinity)
.padding()
.background(Color("Onyx"))
.foregroundColor(Color.white)
.cornerRadius(10)
.sheet(isPresented: self.$show_modal) {
CollectionAddition(userId: session.auth.currentUser!.uid, bottleId: bottle!.id)
}
}
VStack(alignment: .leading) {
Text("Information")
.font(.title3)
.fontWeight(.semibold).padding([.bottom], 1)
Text(bottle?.information ?? "")
.fixedSize(horizontal: false, vertical: true)
}.padding([.bottom])
}
.padding()
.padding(.top)
.background(Color("Tope"))
.cornerRadius(30, corners: [.topLeft, .topRight])
.offset(x: 0, y: -30.0)
}
.edgesIgnoringSafeArea(.top)
}
解决方案
推荐阅读
- android - 移除 android 图标的绿色背景
- angular - Angular Firebase 用户可以读写自己的数据
- git - 如何将两个 git 存储库作为一个存储库进行管理,但又保持独立?
- azure - Terraform 如何定义一个变量以让用户选择现有资源或创建新资源
- r - 如何在 R 中以 50/50 的夜间和白天时间比率为每个人每天提取一个随机的白天?
- oozie-workflow - 我想在 Hue-> Oozie 中安排 Impala 查询
- visual-studio-code - Visual Studio 代码中的键绑定
- c# - 在 UWP 中使用 windows.media.ocr 提高 OCR 的质量
- algorithm - 在 Uncertain equation 或 2 array 中找到相似的部分
- linkedin - 在 iOS 设备中不显示“应用链接”按钮