Closed RZulfikri closed 4 months ago
I think it's due to this code,
layer.superlayer?.addSublayer(secureTextField.layer)
secureTextField.layer.sublayers?.last?.addSublayer(layer)
that code will trigger safeAreaInsetsDidChange
and change the safeAreaInsets.bottom
value to 0
Hi @RZulfikri,
If you've found a solution for the issue, could you please fork this branch to update the code? Additionally, if you'd like to contribute by raising an MR, please feel free to do so. I'll review it and merge it later. Thank you!
finally I found the solution.
@objc func setScreenCaptureProtection() {
the code below makes the main view become blank
// if viewWithTag(Constants.secureTextFieldTag) is UITextField {
// return
// }
//
// guard superview != nil else {
// for subview in subviews {
// subview.setScreenCaptureProtection()
// }
// return
// }
...
the code below cause an error when implementing with window // secureTextField.topAnchor.constraint(equalTo: self.topAnchor, constant: 0).isActive = true // secureTextField.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: 0).isActive = true // secureTextField.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 0).isActive = true // secureTextField.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: 0).isActive = true
}
2. I call window ( `[self.window setScreenCaptureProtection];`) instead of using `view`. The view trigger SafeArea changed.
Hi, I want to thank you for the library, it works perfectly. However, I am having issues with safe-area things. After I add screenshot protection, the bottom inset of the safe-area becomes 0. If I disabled it, it worked normally. I tried to detect the safe-area insets using react-native-safe-area-context. I tried to move the secureTextField to a subview instead of direct view, but no luck. Any advice?