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.
Here is a breakdown of the repository's core components and features.
1. 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: It includes custom states for the device's flash (On, Off, and Auto).
-
Photo Library Integration: For users who prefer to edit existing photos, the controller implements
UIImagePickerControllerto pull and crop images directly from the iOS photo gallery.
2. Typography & GPUImage Filters
Once an image is selected, the application transitions to the EditorPresetTableViewController, which acts as a staging ground for the image's overall "vibe."
-
GPUImage Integration: The app uses
GPUImageToneCurveFilterto apply Instagram-style color grading and filters to the user's cropped image. - Extensive Font Presets: The view controller houses a massive array of typography presets. It defines custom combinations of text colors, background highlights, font sizes, and custom typefaces (featuring fonts like LibreBaskerville, Anton, BebasNeue, and CheddarJack).
-
CoreText Rendering: The text is rendered using CoreText (
CTFontRefandCTParagraphStyle), ensuring high-quality, precise typography on top of the filtered image.
3. Interactive Gesture-Driven Text
The heart of the application is the EditorMakePostViewController, where the final composition takes place. The text overlay logic is handled by a heavily customized PresetLabelView. Instead of relying on standard UILabel components, the developer utilized CoreGraphics and CoreText to draw the text frame directly onto the view's graphics context.
This custom rendering allows for highly fluid, gesture-driven manipulations:
- Double Tap: Summons the keyboard to edit the text (limited to a tweet-like 140 characters).
- Pinch: Dynamically scales the font size up or down based on the pinch scale factor.
-
Rotate: Uses a two-finger rotation gesture to apply a
CGAffineTransformrotation to the text. - Long Press & Drag: Allows the user to freely drag and reposition the text anywhere on the canvas.
4. Freehand Drawing Capabilities
In addition to text, users can draw over their images. By toggling into drawing mode, the app brings an ACEDrawingView to the front of the screen. This integration supports smooth freehand drawing using a pen tool and comes fully equipped with Undo, Redo, and Clear functionalities, enabling users to easily correct mistakes.
5. Custom Color Picker
To customize the text and drawing tools, the repository features a custom ColorPicker UI control. Rather than relying on standard color wheels, this component maps a gradient image and utilizes a UILongPressGestureRecognizer to track the user's finger. It determines the active color by using CGBitmapContextCreate to read the exact RGB and Alpha pixel data at the specific point where the user is touching the screen, updating the active drawing or font color in real-time.
Conclusion
The text-n-drawings-on-image-objc repository is a brilliant showcase of 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: https://github.com/arpad1337/text-n-drawings-on-image-objc
Top comments (0)