Community-maintained Agent Skills for complete Swift and Apple-platform app delivery.
72
90%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Medium
Suggest reviewing before use
Integrate drawing, sketching, and annotation into iOS and iPadOS apps using PencilKit (PKCanvasView, PKToolPicker, PKDrawing) and PaperKit. Targets Swift 6.3 / iOS 26+.
| Component | Responsibility |
|---|---|
PKCanvasView | Scrollable drawing canvas that receives touch and pencil inputs; inherits from UIScrollView |
PKToolPicker | Floating system tool palette offering pens, pencils, markers, erasers, rulers, and custom tools |
PKDrawing | Immutable data model containing vector strokes (PKStroke), stroke points, and bounds |
PKTool | Active drawing instrument (PKInkingTool, PKEraserTool, PKLassoTool) |
PKCanvasViewDelegate | Notifies when drawing changes or user starts/ends drawing |
Bridge PKCanvasView into SwiftUI using UIViewRepresentable:
import SwiftUI
import PencilKit
struct CanvasViewRepresentable: UIViewRepresentable {
@Binding var drawing: PKDrawing
var tool: PKTool = PKInkingTool(.pen, color: .black, width: 5)
var isRulerActive: Bool = false
func makeUIView(context: Context) -> PKCanvasView {
let canvas = PKCanvasView()
canvas.drawingPolicy = .anyInput
canvas.tool = tool
canvas.isRulerActive = isRulerActive
canvas.delegate = context.coordinator
return canvas
}
func updateUIView(_ uiView: PKCanvasView, context: Context) {
if uiView.drawing != drawing {
uiView.drawing = drawing
}
uiView.tool = tool
uiView.isRulerActive = isRulerActive
}
func makeCoordinator() -> Coordinator { Coordinator(self) }
class Coordinator: NSObject, PKCanvasViewDelegate {
var parent: CanvasViewRepresentable
init(_ parent: CanvasViewRepresentable) { self.parent = parent }
func canvasViewDrawingDidChange(_ canvasView: PKCanvasView) {
Task { @MainActor in parent.drawing = canvasView.drawing }
}
}
}drawing.dataRepresentation(). Restore via PKDrawing(data:).drawing.image(from: canvasView.bounds, scale: canvasView.traitCollection.displayScale).drawing.strokes to inspect points, pressure, force, and azimuth.Configure canvasView.drawingPolicy:
.default: Follows system preference (Apple Pencil only if configured in Settings)..anyInput: Allows finger drawing alongside Apple Pencil..pencilOnly: Restricts drawing strictly to Apple Pencil; finger touches scroll the canvas.Coordinating PKToolPicker: Attach the picker with toolPicker.setVisible(true, forFirstResponder: canvasView) and toolPicker.addObserver(canvasView). Ensure the canvas becomes first responder.
PKToolPicker (iOS 18+), read Custom Tool Picker Items.UndoManager, read Undo/Redo Support.canvasView.becomeFirstResponder() before showing PKToolPicker.@Binding var drawing continuously during drawing gestures, causing hitching and feedback loops.drawingPolicy = .pencilOnly.PKToolPicker floats automatically in SwiftUI without anchoring to a window or first responder.PKCanvasView embedded in SwiftUI with a clean CoordinatordrawingPolicy explicitly set (.anyInput, .pencilOnly, or .default)PKToolPicker tied to canvas first responder and visible statedataRepresentation() and restored with error handlingundoManagerPKToolPicker obscures canvas regions.tessl-plugin
skills
accessorysetupkit
references
activitykit
adattributionkit
references
alarmkit
references
app-clips
app-intents
app-store-optimization
app-store-review
apple-on-device-ai
appmigrationkit
audioaccessorykit
references
authentication
references
avfoundation-audio
references
avkit
background-processing
references
browserenginekit
callkit
references
carplay
cloudkit
contacts-framework
references
core-bluetooth
references
core-data
core-haptics
references
core-motion
references
core-nfc
references
coreml
references
cryptokit
cryptotokenkit
debugging-instruments
device-integrity
references
energykit
references
eventkit
family-controls
references
financekit
focus-engine
gamekit
git-branching-workflow
references
healthkit
references
homekit
references
ios-accessibility
ios-app-workflow
references
ios-ettrace-performance
ios-localization
ios-memgraph-analysis
ios-networking
ios-simulator
references
metrickit
references
musickit
references
natural-language
paperkit
references
passkit
references
pdfkit
pencilkit
references
permissionkit
references
photokit
push-notifications
quicklook
references
realitykit
references
relevancekit
references
scenekit
sensorkit
shazamkit
references
speech-recognition
references
spritekit
storekit
swift-api-design-guidelines
swift-architecture
references
swift-charts
swift-codable
references
swift-code-review
swift-concurrency
swift-formatstyle
references
swift-language
swift-security
references
swift-testing
swiftdata
swiftlint
swiftui-animation
swiftui-gestures
references
swiftui-layout-components
swiftui-liquid-glass
references
swiftui-patterns
swiftui-performance
swiftui-responsive-layout
swiftui-uikit-interop
swiftui-webkit
tabletopkit
tipkit
vision-framework
weatherkit
references