[英]SwiftUI removing a space on the view
在 SwiftUI 視圖中,我嘗試顯示一個簡單的 TOP 藍色條、一個紅色矩形和一個下條,正如您從所附圖片中看到的那樣,頂部有一個奇怪的空白區域,頂部的紅色矩形是我的想刪除,但我不明白為什么會在那里。
這是簡單的代碼:
var body: some View {
GeometryReader { geometry in
VStack {
//upper top bar
HStack{
Text("TOP BAR")
}.frame(width: geometry.size.width, height: geometry.size.height/10)
.background(LinearGradient(gradient: Gradient(colors: [Color("BlueW"), Color("DARK")]), startPoint: .topLeading, endPoint: .bottomTrailing).shadow(radius: 2)).edgesIgnoringSafeArea(.all)
// <<<<<<<<<<<<<<<<<<< PROBLEM HERE <<<<<<<<<<<<<<<<<<
// testing rectangle
Rectangle().foregroundColor(.red)
//lower bar
ZStack {
HStack {
Image(systemName: "house")
.resizable()
.aspectRatio(contentMode: .fit)
.padding(20)
.frame(width: geometry.size.width/3, height: 75)
.foregroundColor(self.viewRouter.currentView == "home" ? .black : .gray)
.onTapGesture {
self.viewRouter.currentView = "home"
}
ZStack {
Circle()
.foregroundColor(Color.white)
.frame(width: 75, height: 75)
Button(action: {
self.isAddPresented = true
}) {
Image(systemName: "plus.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 75, height: 75)
.foregroundColor(.green)
.rotationEffect(Angle(degrees: self.showPopUp ? 90 : 0))
}
.sheet(isPresented: self.$isAddPresented) {
AirportView(dm: self.dm, airport: self.general.airportData, dismissFlag: self.$isAddPresented)
}
}
.offset(y: -geometry.size.height/10/2)
.onTapGesture {
withAnimation {
self.showPopUp.toggle()
}
}
Image(systemName: "paperplane.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.padding(20)
.frame(width: geometry.size.width/3, height: 75)
.foregroundColor(self.viewRouter.currentView == "routekit" ? .black : .gray)
.onTapGesture {
self.viewRouter.currentView = "routekit"
}
}.frame(width: geometry.size.width, height: geometry.size.height/10)
.background(LinearGradient(gradient: Gradient(colors: [Color("BlueW"), Color("DARK")]), startPoint: .topLeading, endPoint: .bottomTrailing).shadow(radius: 2))
}
}
}.edgesIgnoringSafeArea(.bottom)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.