问题
What I'm trying to do is I want to hide any ui element when the user receives a screen recording or photo, I sent an email to the screenShield kit site, but didn't get any feedback. I have to try another method. Please help
回答1:
You can detect whether the screen is being recorded or not by using;
UIScreen.main.isCaptured
You can also use notification to track any changes;
NotificationCenter.default.addObserver(self, selector: #selector(didChangeCaptured(_:)), name: UIScreen.capturedDidChangeNotification, object: nil)
@objc func didChangeCaptured(_ notification: Notification) {
if UIScreen.main.isCaptured {
// do something here
} else {
// do something here
}
}
来源:https://stackoverflow.com/questions/65969452/some-items-are-blocked-when-taking-a-screen-recording-or-picture-for-swift