Stampoo/SnapshotSafeView

Value of type 'ScreenshotInvincibleContainerProtocol' has no member 'position'

MallikarjunH opened this issue · 2 comments

Hi, when I am adding code it's giving this error. Please see my code. Any mistake in the code? I copied the code as it is.

Screenshot 2022-07-25 at 11 13 06 AM

Can anyone help me?

Hi @MallikarjunH, this just little wrapper for NSLayoutAnchor API, https://github.com/Stampoo/WrappingAnchor.

U can use this same way 🙂:

final class ExampleViewController: UIViewController {

    var hiddenFromScreenshotButtonController = ScreenshotProtectController(content: UIButton())

    override func viewDidLoad() {
        super.viewDidLoad()
        hiddenFromScreenshotButtonController.content.backgroundColor = .systemRed // UI customization apply to content
        hiddenFromScreenshotButtonController.content.layer.cornerRadius = 20

        view.addSubview(hiddenFromScreenshotButtonController.container)
        /// Instead wrapper
        hiddenFromScreenshotButtonController.container.translatesAutoresizingMaskIntoConstraints = false

        [
            hiddenFromScreenshotButtonController.container.topAnchor.constraint(equalTo: view.topAnchor, constant: 80),
            hiddenFromScreenshotButtonController.container.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20),
            hiddenFromScreenshotButtonController.container.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20),
            hiddenFromScreenshotButtonController.container.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -80)
        ].forEach { $0.isActive = true } // Layout control apply to container

        hiddenFromScreenshotButtonController.setupContentAsHiddenInScreenshotMode() // apply hidden mode
        // content will be removed from system screenshots and screen recording
    }

}

Working fine. Thanks for the update.