我的问题似乎很简单。但是我只是花了几个小时寻找解决方案!
我只需要使状态栏的背景色与我的UINavigationBar
背景色(此示例中为红色)相符即可。
我写了一个最小的代码示例来重现我的问题,并帮助您为我提供解决方案...
TestApp.swift
import SwiftUI
@main
struct TestApp: App {
@Environment(\.scenePhase) private var phase
var body: some Scene {
WindowGroup {
ContentView()
}
.onChange(of: phase) { newPhase in
switch newPhase {
case .active:
UINavigationBar.appearance().backgroundColor = UIColor.red
break
default:
break
}
}
}
}
ContentView.swift
struct DetailView1: View {
var body: some View {
Text("Detail view 1")
}
}
struct ContentView: View {
@State private var isDisplayDetailView1 = true
var body: some View {
NavigationView {
List {
Section {
NavigationLink(destination: DetailView1(), isActive: $isDisplayDetailView1) {
Text("Go to detail view 1")
}
}
}
.navigationBarTitle("Menu")
.listStyle(GroupedListStyle())
DetailView1()
}
}
}
很显然,我尝试将edgesIgnoringSafeArea(.top)
添加到我的NavigationView
视图(以及List
和DetailView1
视图中,...),但是什么都不会改变...请帮助我,我不知道问题出在哪里!
答案 0 :(得分:0)
您使用procedure TForm2.TCPClientStatus(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string);
var
Client: TIdTCPClient;
IO: TIdIOHandler;
begin
Client := nil;
if ASender is TIdTCPClient then begin
Client := TIdTCPClient(ASender);
end
else if ASender is TIdIOHandler then begin
IO := TIdIOHandler(ASender);
if IO.Owner is TIdTCPClient then
Client := TIdTCPClient(IO.Owner);
end;
if Client <> nil then begin
// use Client.Tag as needed...
end;
end;
您只需在ScenePhase
上添加此代码
file scope