Advent · Day 7
This one opens on December 7.
Every door opens at midnight Pacific.
See the calendarPattern · Media
Photo Markup SwiftUI Block
Photo Markup SwiftUI Block is a paid SwiftUI pattern in SwiftPieces Pro. Draw on a photo with a pen, marker and highlighter, drag out arrows, place text and erase, with undo and redo. iOS 17.0 and later. SwiftPieces Pro is $199 once.
Draw on a photo with a pen, marker and highlighter, drag out arrows, place text and erase, with undo and redo.
Buyers also search for this as a SwiftUI section.
| Price | $199 once |
|---|---|
| iOS | iOS 17.0 and later |
| License | A per-developer commercial license for unlimited personal and commercial apps, including client work. Do not resell or redistribute the source as a template or UI kit. |
| Dependencies | No third-party packages. Apple frameworks only. |
| Files | 1 Swift file in the install. |
The markup tool of a photo editor as one section. Smoothed strokes in a pen, a broader marker and a translucent highlighter, arrows you drag out, text labels you place, edit and move, and an eraser that lifts whole items. Ink comes from five swatches and a width slider, and every item is a Codable value normalized to the photo, so a drawing renders onto the full-resolution photo at any size.
- SwiftUI
- iOS 17.0+
- photo-markup
$199 once, every piece included. See how installing works · Sign in
Proof
This targets iOS 17.0 and later. On iOS 26 it uses Liquid Glass. On iOS 17 through iOS 18 it uses a material fallback, including when Reduce Transparency is on.
No simulator still is published for this page yet.
01
What's included
SwiftUI source you own, built on Apple frameworks only.
- Pen, marker and highlighter with smoothed strokes
- Arrows, and text you tap to edit and drag to move
- An eraser that lifts whole items
- Five swatches including the system colour picker, and a width slider
- Codable items and
render(over:)at full resolution
Used in
Photo Editor (screen)
02
Implementation notes
How it behaves, what it handles, and the decisions behind it.
The photo sits on a stage, and you draw straight on it. The pen draws a narrow line, the marker a broader one and the highlighter a wide translucent band that multiplies with the photo. All three are smoothed through the midpoints of your touches. The arrow tool drags out an arrow with its head sized to the line. The text tool places a label you type into. Tap any label to edit it again, or drag it into place, and a label left empty disappears. The eraser lifts whole items it touches. Above the tools, undo and redo sit at either end of the row, with the tool's name between them. Under the tools are five swatches (your text colour, the accent, white, black and the system colour picker) and a width slider drawn as a growing wedge. Apple Pencil draws through the same gesture.
Notes
PhotoMarkupBlock(image:drawing:)binds aPhotoMarkupBlock.Drawing. Passing nil draws a ghost.- A
Drawingis a list ofItems, in drawing order. EachItemhas akind(pen, marker, highlighter, arrow or text),pointsnormalized 0...1 to the photo, anInk(plain sRGB numbers), awidthas a fraction of the photo's width, andtext. Everything isCodable, so a drawing is saved with the edit and redrawn at any size. drawing.render(over:)paints the drawing on the photo at its own resolution. Widths and text sizes scale with the image. It uses UIKit drawing, so call it on the main actor.- PencilKit is not used. Items stay plain values you can store, diff and render anywhere.
- Undo and redo keep up to 50 steps of the block's own changes. A screen around it can keep its own history too, as Photo Editor does.
- The swatch for your text colour resolves the theme's colour at the moment you draw, so a stroke keeps its colour if the appearance changes later.
- VoiceOver reads each tool and swatch, marks the chosen one, reads text labels and offers editing, and the width slider is adjustable.
PhotoMarkupBlockExampleis the preview: the painted sample photo with the sun circled in red and a "golden hour" caption.
Theming
The block reads these tokens:
surfacefor the stage.textPrimaryfor the tool name, the chosen tool, the ink swatch, the selection rings and the width wedge.textSecondaryfor the other tools,textTertiaryfor undo and redo when there is nothing to undo.fillbehind the chosen tool,separatoraround swatches.accentas a swatch.radius.lgandmotion.snappy.
03
Keep building
Pieces that work well next to this one.