iOS 防止截屏录屏
通过官方 api 无法实现
这里通过 UITextField.isSecureTextEntry
奇技淫巧, 截屏时系统自动隐藏内容实现
通知
-
UIApplication.userDidTakeScreenshotNotification
截屏通知 (截图已经保存相册) -
UIScreen.capturedDidChangeNotification
录屏通知
密码框
let textfeild = UITextField()
textfeild.isSecureTextEntry = true
self.view.addSubview(textfeild)
截屏/录屏 一劳永逸
- 设置 UITextField.isSecureTextEntry
- 将私密内容放在
UITextField
中 - 截图后
scrollView
被隐藏
// textfeild
let textfeild = UITextField(frame: self.view.bounds)
textfeild.isSecureTextEntry = true
self.view.addSubview(textfeild)
// scrollView
if let view = textfeild.subviews.first {
view.isUserInteractionEnabled = true
view.addSubview(scrollView)
}else{
textfeild.addSubview(scrollView)
}
// other ...
网友评论