出于安全原因,我需要阻止我的应用用户截屏.我显示的内容是保密的,不应复制到设备上.我在Stack Overflow上看到了一个答案,但对于Android.
是否有可能在iOS中阻止屏幕捕获?
通过点击几个按钮将屏幕截图捕获到图库中对于用户来说是一个非常有用的功能,但是对它的预防也是有限的.有什么指针吗?
Jim*_*ett 15
另一个问题是湿软件中的屏幕捕获 - 就像一个人用另一个设备(如相机或其他手机)捕获屏幕一样.即使你在应用程序中阻止它,也不可能阻止某人拍摄屏幕照片
ora*_*ull 11
我刚刚编写了 UIView 的简单扩展,允许将其隐藏在屏幕捕获、Airplay 镜像等中。该解决方案使用 UITextField 的功能来隐藏密码以防止捕获。
extension UIView {
func makeSecure() {
DispatchQueue.main.async {
let field = UITextField()
field.isSecureTextEntry = true
self.addSubview(field)
field.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
field.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
self.layer.superlayer?.addSublayer(field.layer)
field.layer.sublayers?.first?.addSublayer(self.layer)
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用:
class ViewController: UIViewController {
var secureView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
secureView.makeSecure()
}
}
Run Code Online (Sandbox Code Playgroud)
如果有人解释 Apple 如何在内部实现这种魔力,我将不胜感激。
已经有一段时间了,但我刚刚遇到了ScreenShieldKit,这是消息应用程序 Confide 使用的一项正在申请专利的技术。它的作用是让用户截取屏幕截图,但最终图片上的内容是空白的。他们最近发布了iOS版本。
移至背景之前,请从视图中删除敏感信息。当应用程序过渡到后台时,系统会为应用程序的主窗口拍摄快照,然后在将应用程序过渡回前台时短暂呈现该快照。从applicationDidEnterBackground方法返回之前,您应该隐藏或遮盖可能作为快照一部分捕获的密码和其他敏感个人信息。
在Swift 4中,将此代码添加到您的应用程序委托中。
在应用程序委托中声明一个变量
var imageview : UIImageView?
func applicationWillResignActive(_ application: UIApplication) {
imageview = UIImageView.init(image: UIImage.init(named: "bg_splash"))
self.window?.addSubview(imageview!)
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidBecomeActive(_ application: UIApplication) {
if (imageview != nil){
imageview?.removeFromSuperview()
imageview = nil
}
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
65347 次 |
最近记录: |