Docs
Media

SnapshotNew

Turns any view into an image like a screenshot: a flash, then a tilted thumbnail you tap to share and a glass note.

By

Snapshot: SwiftUI View Snapshot and Share Image for iOS, live preview in light mode

Snapshot, a SwiftUI View Snapshot and Share Image for iOS 17+, in its live preview. Open Code for the Swift source.

$npx swiftpieces add Snapshot
Free · MIT + Commons ClauseiOS 17.0+Liquid Glasssnapshotscreenshotshareimagerenderexportthumbnail
Type
Snapshot
Files
Snapshot.swift
Depends on
Nothing (Apple frameworks only)
Version
1.0.0

Sizes, timing and colors for Snapshot.

Notes

  • Captures its content with ImageRenderer at the screen's scale each time trigger changes, so the image is as crisp as the screen. onCapture hands you the UIImage to copy, save or upload.
  • The content is drawn a second time, off screen, for the image, in the current colour scheme. Build it from values, not from state that only lives inside it, or the picture can differ from the screen.
  • A white flash runs over the view, then the picture shrinks to thumbnailScale with a slight tilt into a white-framed thumbnail thumbnailDrop points below the view. Leave room there: it draws outside the view's frame.
  • The thumbnail is a ShareLink, so a tap opens the share sheet with the image. A glass note beside it shows message with a red check, and both slide away after holdDuration seconds.
  • A medium haptic fires as the picture is taken, and VoiceOver announces message.
  • Under Reduce Motion the flash is softer, the thumbnail does not tilt and every move runs without bounce.

Usage

SnapshotExample()

Install

Pick one. Run it from the folder that contains your .xcodeproj and the files land inside your app.

Terminal

$npx swiftpieces add Snapshot

Or ask your coding agent · Claude Code, Cursor or Xcode, once the MCP server is connected

>Add the SwiftPieces "Snapshot" piece to my app

Or copy the source above into your app.

New to SwiftUI?If you know React, CSS or Tailwind, SwiftUI is easier to pick up than it looks.Try real app patterns first

Building a whole app? See SwiftPieces Pro →

All media →

Build it yourself: SwiftUI animations guide

On this page

SwiftPiecesPro

Build the whole app with one library.

Production-ready screens, whole flows, complete app templates, a Build Kit your agent follows and Pro remixing.

Explore Pro