Skip to content

unionst/union-screenshots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnionScreenshots

A SwiftUI package for controlling view visibility during screen capture and displaying content behind the Dynamic Island.

Screenshot Mode Dynamic Island
Watermark Demo Dynamic Island Demo

Features

  • Screenshot Mode: Hide or reveal views in screenshots and recordings
  • Screenshot Replacement: Swap views with different content in screenshots
  • Dynamic Island Background: Display content behind the Dynamic Island or notch
  • Automatic background color sampling for watermarks
  • Light/dark mode support

Requirements

  • iOS 18.0+
  • Swift 6.2+

Installation

Add the package to your Xcode project:

dependencies: [
    .package(url: "https://github.com/unionst/union-screenshots.git", from: "1.2.0")
]

Screenshot Mode

Control how views appear during screen capture.

Secure

Hide content from screenshots and recordings:

Text("Secret Code: 1234")
    .screenshotMode(.secure)

Watermark

Show content only in screenshots (hidden during normal use):

Text("CONFIDENTIAL")
    .screenshotMode(.watermark)

The background color is automatically sampled. Watermarks work best on solid, opaque backgrounds.

For explicit control:

Text("CONFIDENTIAL")
    .screenshotMode(.watermark(background: .white))

Text("CONFIDENTIAL")
    .screenshotMode(.watermark(background: .regularMaterial))

Visible

Use for conditional logic:

Text("Hello")
    .screenshotMode(isProtected ? .secure : .visible)

Screenshot Replacement

Replace a view with different content in screenshots:

Text("Secret: 1234")
    .screenshotReplacement {
        Text("Nice try!")
    }

Dynamic Island Background

Display content behind the Dynamic Island or notch.

ContentView()
    .dynamicIslandBackground {
        Image(.logo)
            .resizable()
            .scaledToFit()
    }

With conditional visibility:

.dynamicIslandBackground(isRecording) {
    HStack {
        Circle().fill(.red).frame(width: 8, height: 8)
        Text("REC").font(.caption2)
    }
}

With alignment:

.dynamicIslandBackground(alignment: .leading) {
    Text("Live").font(.caption2)
}

API

// Screenshot modes
enum ScreenshotMode {
    case visible
    case secure
    case watermark
    static func watermark(background: some ShapeStyle) -> ScreenshotMode
}

func screenshotMode(_ mode: ScreenshotMode) -> some View

// Screenshot replacement
func screenshotReplacement<Replacement: View>(
    @ViewBuilder _ replacement: () -> Replacement
) -> some View

// Dynamic Island background
func dynamicIslandBackground<Content: View>(
    _ isVisible: Bool = true,
    alignment: HorizontalAlignment = .center,
    @ViewBuilder content: @escaping () -> Content
) -> some View

How It Works

Screenshot Mode uses the same mechanism iOS uses for SecureField to hide content from screen capture.

Dynamic Island Background creates a UIWindow overlay at a high window level that appears behind the Dynamic Island cutout.

License

MIT

About

Add branding to users' screenshots

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages