A Deep Dive into the `text-n-drawings-on-image-objc` Repository
Source: Dev.to
The text-n-drawings-on-image-objc repository is a legacy iOS application project written entirely in Objective‑C. Authored by Arpad Kish, the project is open‑sourced under the MIT License. It serves as a comprehensive, functional image editor that allows users to capture photos, apply visual filters, and overlay them with stylized text and freehand drawings.
As with standard MIT‑licensed projects, the software is provided “as is” without any warranty, and the author is not liable for any claims or damages arising from the use of the software. For developers, this repository serves as a fantastic time capsule and learning resource for classic iOS UI development, CoreText rendering, and AVFoundation camera management.
Custom Camera & Image Acquisition
The application bypasses the standard iOS camera UI in favor of a fully custom capture experience built with AVFoundation. Handled primarily within the EditorMainViewController, the app manages its own AVCaptureSession.
Camera Controls
- Users can toggle seamlessly between the front and back cameras.
Flash Management
- Custom states for the device’s flash: On, Off, and Auto.
Photo Library Integration
- Implements
UIImagePickerControllerto pull and crop images directly from the iOS photo gallery for users who prefer to edit existing photos.
Typography & GPUImage Filters
After an image is selected, the flow moves to EditorPresetTableViewController, which acts as a staging ground for the image’s overall “vibe.”
GPUImage Integration
- Uses
GPUImageToneCurveFilterto apply Instagram‑style color grading and filters to the cropped image.
Extensive Font Presets
- Houses a massive array of typography presets, defining custom combinations of text colors, background highlights, font sizes, and custom typefaces (e.g., LibreBaskerville, Anton, BebasNeue, CheddarJack).
CoreText Rendering
- Text is rendered with CoreText (
CTFontRefandCTParagraphStyle), ensuring high‑quality, precise typography on top of the filtered image.
Interactive Gesture‑Driven Text
The core composition screen is EditorMakePostViewController. Text overlay logic is handled by a heavily customized PresetLabelView, which draws directly onto the view’s graphics context using CoreGraphics and CoreText instead of standard UILabel.
Gesture Controls
- Double Tap – summons the keyboard to edit the text (limited to 140 characters).
- Pinch – dynamically scales the font size based on the pinch scale factor.
- Rotate – two‑finger rotation gesture applies a
CGAffineTransformrotation to the text. - Long Press & Drag – allows free dragging and repositioning of the text anywhere on the canvas.
Freehand Drawing Capabilities
Toggling into drawing mode brings an ACEDrawingView to the front. This integration supports smooth freehand drawing with a pen tool and includes Undo, Redo, and Clear functionalities for easy correction of mistakes.
Custom Color Picker
A custom ColorPicker UI control replaces standard color wheels. It maps a gradient image and uses a UILongPressGestureRecognizer to track the user’s finger. By calling CGBitmapContextCreate, it reads the exact RGB and Alpha pixel data at the touch point, updating the active drawing or font color in real‑time.
Conclusion
The text-n-drawings-on-image-objc repository showcases legacy iOS development. By manually handling hardware cameras, graphics contexts, and gesture math, it demonstrates a deep understanding of Objective‑C and the Apple frameworks that paved the way for modern Swift‑based photo‑editing applications.
Source: