【发布时间】:2020-05-07 17:05:17
【问题描述】:
无法使 NavigationView 完全扩展 Y 方向。 尝试了 .edgesIgnoringSafeArea(.all) 和 .frame() 的所有选项。 Preview Provider 显示一切都很酷,但 Simulator 和真实设备显示相反。 (附图片)
代码:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView{
ZStack{
Color.blue
VStack{
Text("Hello, World!")
.foregroundColor(Color.blue)
.fontWeight(.bold)
.font(.system(size: 36))
}
}
.navigationBarHidden(true)
.navigationBarTitle("")
.navigationBarBackButtonHidden(true)
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .center)
.edgesIgnoringSafeArea(.all)
}
}
}
【问题讨论】:
-
适用于 Xcode 11.4 / iOS 13.4
-
谢谢,但我真的不明白为什么这对你有用。我已经掌握了 Xcode 11.4.1 版和装有 iOS 13.4.1 的设备,更不用说大量的模拟器了
标签: swift