Some items are blocked when taking a screen recording or picture for swift [closed]

谁都会走 提交于 2021-02-05 09:27:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!