Swiftpack.co - Stampoo/SnapshotSafeView as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Stampoo.
Stampoo/SnapshotSafeView 0.2.1
Used for hide view from system screenshots and video recording
⭐️ 67
🕓 1 year ago
iOS
.package(url: "https://github.com/Stampoo/SnapshotSafeView.git", from: "0.2.1")

SnapshotSafeView

Used for hide view from system screenshots and video recording.

Categories

  1. How install

  2. Requirements

  3. Progress

  4. How usage

    4.1. SwiftUI

    4.2. UIKit


How install


Requirements

  • Xcode version: 12.5.1 or higher
  • Deployment target iOS v12 or higher
  • Swift toolchain 5.5

Progress:

  • Dinamicaly enable/disable hiding from system screenshots and videorecordings(disabling not working yet) Done
  • Run from init(coder:)
  • position inside content with autolayout(now frame based only) Done
  • Support SwiftUI
  • Improve API
  • Support React-Native Done
  • Support Flutter

How usage:

SwiftUI

import SwiftUI
import SnapshotSafeView

struct ContentView: View {

    @State var isNeedHiddenContentFromScreenshots: Bool = false

    var body: some View {
        Text("Hello, world!")
            .padding()
            .background(Color.brown)
        Text("Hello, world!")
            .padding()
            .background(Color.blue)
            .hiddenFromSystemSnaphotWithDefaultPadding(when: isNeedHiddenContentFromScreenshots)
        Text("Hello, world!")
            .padding()
            .background(Color.orange)
        Button("Toggle hide from screenshots condition") {
            isNeedHiddenContentFromScreenshots.toggle()
        }

        Spacer()

        Text(isNeedHiddenContentFromScreenshots ? "Will be hidden from snapshots" : "Will be appear in snapshots")
            .padding()
            .background(isNeedHiddenContentFromScreenshots ? Color.green : Color.red)

    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Example:

UIKit

Warning: This is experimental API, be careful

let someView = UIView()

someView.translatesAutoresizingMaskIntoConstraints = false
someView.topAnchor.constraint(superView.topAnchor, constant: 12).isActive = true
someView.setupAsHiddenFromScreenshot()

or:

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)
        hiddenFromScreenshotButtonController.container.translatesAutoresizingMaskIntoConstraints = false

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

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

}

Example:

GitHub

link
Stars: 67
Last commit: 21 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics