A powerful and reusable image annotation system for iOS built with Swift. Supports drawing, selection, movement, markers, and coordinate export — designed for real-world apps.
- ✏️ Freehand drawing on images
- 📍 Add markers with draggable support
- 🔲 Select annotations using bounding box
↔️ Move selected drawings- 🧽 Eraser with segment-level precision
- 🖼️ Export annotated image
- 📦 Export marker coordinates
- 🎨 Custom color picker support
The system is divided into modular components:
Handles touch input, line rendering, and erasing logic.
Allows selecting drawn segments using a bounding box and moving them.
Supports adding and dragging markers across the image.
- Converts drawing into an image
- Extracts coordinates for backend usage
Add a DrawingView to your view controller:
@IBOutlet weak var drawingView: DrawingView!drawingView.enableDrawingMode()
drawingView.enableEraserMode()
drawingView.startSelectionMode()// Export image
let image = drawingView.exportAsImage()
// Export marker points
let points = drawingView.getMarkerPointsOnImage()Includes a reusable hex-based color picker:
let picker = CustomColorPickerView(colorHexes: ["#FF0000", "#00FF00"])
picker.onColorPicked = { color in
drawingView.drawingColor = color
}Currently, drawing behavior is controlled using multiple flags:
isDrawingEnabledisEraserEnabledisSelectionModeisSelectionMovementMode
👉 For better scalability, this can be replaced with a single mode-based approach:
enum DrawingMode {
case draw
case marker
case eraser
case selection
case move
}This avoids conflicting states and improves maintainability.
- Inspection apps (mark damaged areas)
- Delivery/photo verification
- Image annotation tools
- AI/ML preprocessing
Read full explanation here: 👉 https://medium.com/@manpreet.s_92558/build-an-image-annotation-system-in-ios-draw-select-move-export-coordinates-00b319ec870e
- Swift
- UIKit
- Core Graphics
- Touch Handling
Built with 💙 by Manpreet Singh