back to home

TimOliver / TOCropViewController

A view controller for iOS that allows users to crop portions of UIImage objects

4,918 stars
1,019 forks
101 issues
Objective-CSwiftRuby

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing TimOliver/TOCropViewController in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/TimOliver/TOCropViewController)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

TOCropViewController is an open-source subclass to crop out sections of objects, as well as perform basic rotations. It is excellent for things like editing profile pictures, or sharing parts of a photo online. It has been designed with the iOS Photos app editor in mind, and as such, behaves in a way that should already feel familiar to users of iOS. For Swift developers, is a Swift wrapper that completely encapsulates and provides a much more native, Swiftier interface. Proudly powering apps by _Looking for something more? If doesn't meet your exact requirements, please consider IMG.LY with video editing and photo filter capabilities instead! (Disclaimer: Affiliate Link)_ Features • Crop images by dragging the edges of a grid overlay. • Optionally, crop circular copies of images. • Rotate images in 90-degree segments. • Clamp the crop box to a specific aspect ratio. • A reset button to completely undo all changes. • iOS 7/8 translucency to make it easier to view the cropped region. • The choice of having the controller return the cropped image to a delegate, or immediately pass it to a . • A custom animation and layout when the device is rotated to landscape mode. • Custom 'opening' and 'dismissal' animations. • Localized in 28 languages. System Requirements iOS 12.0 or above. _Disclaimer: visionOS and Mac Catalyst modes are also enabled, however they are not officially supported. PRs are always welcome!_ Installation CocoaPods Objective-C Add the following to your Podfile: Swift Add the following to your Podfile: Swift Package Manager Add the following to your : Carthage • Add the following to your Cartfile: • Run • From the folder, import one of the two frameworks into your Xcode project. For Objective-C projects, import just and for Swift, import instead. Each framework is separate; you do not need to import both. • Follow the remaining steps on Getting Started with Carthage to finish integrating the framework. Manual Installation All of the necessary source and resource files for are in , and all of the necessary Swift files are in . For Objective-C projects, copy just the directory to your Xcode project. For Swift projects, copy both and to your project. Examples Using is very straightforward. Simply create a new instance passing the object you wish to crop, and then present it modally on the screen. While prefers to be presented modally, it can also be pushed to a stack. For a complete working example, check out the sample apps included in this repo. Basic Implementation Swift Objective-C Similar to many subclasses, like , the class responsible for presenting view controller should also take care of dismissing it upon cancellation. To dismiss , implement the delegate method, and call from there. Making a Circular Cropped Image Swift Objective-C Sharing Cropped Images Via a Share Sheet Swift Objective-C Presenting With a Custom Animation Optionally, also supports a custom presentation animation where an already-visible copy of the image will zoom in to fill the screen. Swift Objective-C Architecture of While traditional cropping UI implementations will usually just have a dimming view with a square hole cut out of the middle, goes about its implementation a little differently. Since there are two views that are overlaid over the image (A dimming view and a translucency view), trying to cut a hole open in both of them would be rather complex. Instead, an image view is placed in a scroll view in the background, and a copy of the image view is placed on top, inside a container view that is clipped to the designated cropping size. The size and position of the foreground image is then made to match the background view, creating the illusion that there is a hole in the dimming views, and minimising the number of views onscreen. Credits was originally created by Tim Oliver as a component for iComics, a comic reader app for iOS. Thanks also goes to 's growing list of contributors! iOS Device mockups used in the screenshot created by Pixeden. License TOCropViewController is licensed under the MIT License, please see the LICENSE file.