我希望背景图像和绿色 UI 元素位于屏幕顶部,但代码位于绿色 UI 元素下方的中间。
代码:
struct AppointmentStep1: View {
@Environment(\.dismiss) var dismiss
var body: some View {
ZStack {
// Background image
Image("home_bg")
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
VStack {
HStack {
Button {
dismiss()
} label: {
Image(systemName: "arrow.left")
.font(.system(size: 25))
.tint(.white)
.padding(.trailing, 6)
}
Text("Appointment")
.font(.calibriRegular(with: 20))
.foregroundStyle(.white)
Spacer()
}
.padding(16)
}
.background(
Color.appGreen2
.ignoresSafeArea()
)
Spacer()
}
}
}
o/p:如何将绿色视图移至顶部
[![在此处输入图像描述][1]][1]
编辑:
这是我的背景图片:请尝试使用这个背景..我总是得到相同的o/p