我是SwiftUI的新手并使用標簽欄。在我的標簽欄中有 4 個視圖,我為每個視圖制作了不同的類。現在我為矩形使用 VStack,但這些矩形隱藏在標簽欄后面。我為此附上截圖:

這是我的代碼:
struct ReportIncidentView: View {
var body: some View {
ZStack(alignment: .bottom) {
LinearGradient(gradient: Gradient(colors: [Color(ColorName.gradient1.rawValue), Color(ColorName.appBlue.rawValue)]), startPoint: .top, endPoint: .bottom)
VStack(alignment: .leading) {
Text("Start Questionairre")
.foregroundColor(.white)
.font(.custom(InterFont.semiBold.rawValue, size: 30))
.padding()
VStack(spacing: -1) {
NavigationLink(destination: HitandRunView()
.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)
){
reportIncidentsView(text1: "Car accident", text2: "Report accident here", corners: [.topRight])
}
Rectangle()
.frame(height: 2)
.foregroundColor(Color(ColorName.emailColor.rawValue))
NavigationLink(destination: HitandRunView()
.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)
) {
reportIncidentsView(text1: "Crime incidenct", text2: "Report crime here", corners: [])
}
}
}
}.ignoresSafeArea()
}
}
有人可以告訴必須做什么才能出現在標簽欄上嗎?
uj5u.com熱心網友回復:
盡量不要忽略所有安全區域,只忽略最上面的一個:
.ignoresSafeArea(edges: .top)代替.ignoresSafeArea()
uj5u.com熱心網友回復:
您應該只忽略頂部的安全區域,而不是底部。如果您忽略所有安全區域,您的內容將與螢屏的底部邊緣對齊,而忽略標簽欄。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/459924.html
標籤:迅速 代码 迅捷 标签栏 swiftui-tabview
