JayantBadlani / ScreenShield

ScreenShield is an iOS library that provides a simple way to protect your app's content from being captured or recorded by screenshots, screen recordings, or other screen capture methods. It works by adding a secure layer on top of your views, which prevents most screen capture mechanisms from recording the underlying content.
MIT License
89 stars 15 forks source link

my layout break #15

Closed TaezIT closed 3 months ago

TaezIT commented 3 months ago

I use ScreenShield.swift file in my project. But when I call ScreenShield.shared.protect(view: self.view) with view is superview of viewcontroller, my layout will be break. I tried to fix it but I think the problem is here layer.superlayer?.addSublayer(textField) textField.layer.sublayers?.last?.addSublayer(layer)

How can I fix it

JayantBadlani commented 3 months ago

Hello @TaezIT ,

Preventing screen capture in an iOS app presents challenges due to the lack of direct support from the iOS operating system. In our library, we've customized our code with various hacks and workarounds to achieve the desired result. Users may encounter occasional issues with a disrupted UI. To address this, consider the following approaches for different frameworks:

To address the layout issue, consider: For UIKit: To prevent the layout issue by incorporating "ScreenShield" protection to your view after the UI finishes loading. Implementing this protection in the viewDidAppear method can effectively mitigate layout problems.

Check Readme Note for details: https://github.com/JayantBadlani/ScreenShield/blob/main/README.md

TaezIT commented 3 months ago

I wrote this in viewDidAppear and DispatchQueue but my layout still break I write this with another view different superview -> it will active normal