ios - SwiftUI:如何让内容与屏幕顶部对齐,但保留后退按钮
问题描述
我正在学习 SwiftUI(使用 Swift 5,针对 iOS 13.2)
问)我如何才能让我的照片(和下面的内容)在缺口区域后面对齐?
到目前为止我在模拟器中得到了什么:
如您所见,我已经了解了如何使用内联导航栏样式。
我想要的是
查看代码:
import SwiftUI
struct DrinkDetail: View {
var drink: Drink
var body: some View {
List {
ZStack(alignment: .bottom) {
Image(drink.imageName)
.resizable()
.aspectRatio(contentMode: .fit)
Rectangle()
.frame(height: 80.0)
.opacity(0.75)
.blur(radius: 10)
HStack {
Text(drink.name)
.font(.largeTitle)
.foregroundColor(.white)
.padding(8)
Spacer()
}
}
.listRowInsets(EdgeInsets())
Text(drink.description)
.font(.body)
.foregroundColor(.primary)
.lineLimit(nil)
.padding(.bottom, 50.0)
.lineSpacing(12)
HStack {
Spacer()
Button(action: {}) {
Text("Order me")
}
.frame(width: 200.0, height: 50.0)
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
Spacer()
}
}
.edgesIgnoringSafeArea(.top)
.navigationBarTitle(Text(""), displayMode: .inline)
}
}
解决方案
看起来这根本不可能,尽管我之前看过的教程显示它是可能的。
在另行通知之前,这是唯一的方法:https ://stackoverflow.com/a/65523676/12299030
推荐阅读
- r - 如何根据不同data.frame中的因子将带有因子的列添加到data.frame
- three.js - 用于附加/分离组件的框架状态组件
- windows-installer - Windows 安装程序版本 4.5.6002 24433
- python - 如何找到拟合到 5 阶的(卡方)曲线的参数误差?
- swagger-2.0 - Swagger UI 不在其 url 中显示模块名称,并且
- python-3.x - pip安装.whl文件只生成*.dist-info文件夹
- javascript - 使用扩展 API 更改 Chrome 帐户
- scala - 基于条件的多列总和
- openrefine - 通过 GraphDB 设置 OpenRefine 协调端点
- php - 提交后删除 symfony 表单域