Skip to content
QR Code Sheet preview
Rendered from the SwiftUI source on this page.

QR Code Sheet

From syxUI — written for both platforms, not translated between them.

A shareable QR-code sheet.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

QRSheet.swift
// QR Code Sheet · syxUI · https://syxui.dev/components/sheet-qr
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

func shCard<C: View>(_ w: CGFloat, radius: CGFloat = 18, @ViewBuilder _ c: () -> C) -> some View {
    c().frame(width: w).background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: radius, style: .continuous)).overlay(RoundedRectangle(cornerRadius: radius, style: .continuous).stroke(Color.primary.opacity(0.07), lineWidth: 1)).shadow(color: .black.opacity(0.05), radius: 12, y: 5)
}

// QR code sheet
struct QRSheet: View {
    var body: some View {
        shCard(280, radius: 22) {
            VStack(spacing: 14) {
                Capsule().fill(Color.primary.opacity(0.2)).frame(width: 36, height: 5)
                Text("My QR Code").font(.system(size: 17, weight: .semibold))
                Image(systemName: "qrcode").font(.system(size: 120)).foregroundStyle(.primary)
                Text("Scan to add me as a friend").font(.system(size: 13)).foregroundStyle(.secondary)
            }.padding(.horizontal, 18).padding(.top, 12).padding(.bottom, 20)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17