import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello").onReceive(NotificationCenter.default.publisher(for: UIApplication.willResignActiveNotification)) { _ in
print("Enter background")
}
Text("Hello").onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
print("Enter foreground")
}
Text("Hello").onReceive(NotificationCenter.default.publisher(for: UIApplication.userDidTakeScreenshotNotification)) { _ in
print("User screenshot")
}
}
}
SwiftUI:NotificationCenter willResignActiveNotification willEnterForegroundNotification
最新推荐文章于 2024-02-17 11:22:01 发布