如何将状态栏背景颜色更改为其他颜色。我正在使用NavigationView和ZStack。
例如,我希望绿色导航栏上方的白色区域为绿色。我该如何更改?
我尝试过的事情
这是我的NavigationBar代码:
init() {
UINavigationBar.appearance().largeTitleTextAttributes = [
.foregroundColor : UIColor(#colorLiteral(red: 0.8745098039, green: 0.3411764706, blue: 0, alpha: 1))]
UINavigationBar.appearance().backgroundColor = UIColor(named: "backgroundColor")
}
这是我的应用程序背景色代码:
var body: some View {
NavigationView {
ZStack {
Color("backgroundColor")
.edgesIgnoringSafeArea(.all)
}
.navigationBarTitle(Text("Agenda"))
}
}
}
最后但并非最不重要的是我的场景委托代码:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let newAppearance = UINavigationBarAppearance()
newAppearance.configureWithOpaqueBackground()
newAppearance.backgroundColor = .black
newAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]
UINavigationBar.appearance().standardAppearance = newAppearance
//Other code for displaying the first screen
}
答案 0 :(得分:5)
尝试这一行代码
{
"nonClinicalIndicator": "Y",
"questionId": 258,
"questionId2": 1738,
"questionText": "How much of your medication(s) do you have left? For insurance purposes you must provide exact number of pills, injections, doses etc",
"answerId": 0,
"answerType": "SINGLE_SELECT",
"responseFieldIdentifier": "DOSE LEFT IND",
"answerOption": [{
"answerOptionId": 2559,
"answerOptionId2": 1639,
"answerText": "Yes",
"subQuestion": [{
"question": [{
"nonClinicalIndicator": "Y",
"questionId": 2560,
"questionId2": 18740,
"questionText": "Quantity remaining",
"answerId": 0,
"answerType": "TEXT_NUMBER",
"responseFieldIdentifier": "DOSE LEFT"
},
{
"nonClinicalIndicator": "Y",
"questionId": 2561,
"questionId2": 16141,
"questionText": "When will you take your next dose?",
"answerId": 0,
"answerType": "TEXT_DATE",
"responseFieldIdentifier": "NEXT DOSE"
}
]
}],
"isChecked": false
},
{
"answerOptionId": 2562,
"answerOptionId2": 142,
"answerText": "No",
"isChecked": false
}
]
}