Docs
Media

QR CodeNew

A styled QR code with round dots, soft eyes with red centres and your logo, whose dots ripple out from the centre when it changes.

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

Colors for QRCode. A code is always dark on light, so it scans in dark mode too: these don't follow the appearance.

Notes

  • Encodes any string with Core Image's own QR generator at the highest error correction, H, so the logo in the middle and the rounded dots still scan. Use it for links, text, WIFI: logins and contact cards.
  • Drawn in one Canvas: round dots, three finder eyes with soft corners and red centres, and an optional logo on a red tile in a cleared square at the centre. It fills the square it is given and stays crisp at any size.
  • When the content changes, a ring spreads from the centre: dots the new code drops shrink away and dots it adds pop in.
  • A code is always dark on a light card, in dark mode too, so it scans. Recolour the dots, eye centres, card and logo tile through QRCode.Style.
  • To share it as an image, render it with ImageRenderer(content: QRCode(text).frame(width: 600)).
  • VoiceOver reads it as an image, "QR code", with what it encodes as its value.
  • Under Reduce Motion the new code appears at once.

Usage

QRCodeExample()

Install

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

Terminal

$npx swiftpieces add QRCode

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

>Add the SwiftPieces "QR Code" 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