【发布时间】:2021-03-06 12:01:27
【问题描述】:
我想将顶部安全区域的背景颜色从绿色更改为灰色。我到处寻找,但找不到任何解决方案。预览画面是这样的。
我的代码:
struct ContentView: View {
@State var name = ""
init() {
//Use this if NavigationBarTitle is with Large Font
UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: UIColor.red]
UINavigationBar.appearance().backgroundColor = .gray
}
var body: some View {
NavigationView {
ZStack{
VStack{
TextField("Name", text: $name)
.frame(height:200)
.padding()
.background(backgrounImage())
.overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.gray,lineWidth: 4))
.padding()
Spacer()
}.navigationTitle("Tanvir")
.background(Color.green.edgesIgnoringSafeArea(.all))
}
}
}
}
【问题讨论】:
标签: swiftui