Introduction
TOCropViewController is an open-source, easy-to-use, and customizable view controller for cropping and editing images.
Features
Basic Cropping
Easily crop images using a simple and intuitive interface. Rotate, zoom, and move the crop box to precisely select the desired portion of the image.
Customization Options
- Customize the appearance of the cropping interface, including crop box color, background color, and button styles.
- Enable or disable aspect ratio locking to restrict cropping to specific aspect ratios.
- Specify the minimum and maximum crop box sizes.
- Add overlays on top of the image for additional customization.
Image Editing
- Apply basic image transformations, such as rotation, scaling, and flipping.
- Add filters to enhance or alter the image’s appearance.
- Adjust brightness, contrast, saturation, and other image parameters.
Output Options
Choose the desired output format and quality for the cropped image. TOCropViewController supports JPEG, PNG, and other popular image formats.
Integration
Installation
To use TOCropViewController in your project:
- Include the TOCropViewController library in your project.
- Import the TOCropViewController header in your view controller.
Usage
To present TOCropViewController for cropping an image:
- Create an instance of TOCropViewController, providing the image to be cropped.
- Set the delegate of TOCropViewController to receive cropping completion callbacks.
- Present TOCropViewController modally in your view controller.
- Handle the cropping completion callbacks to retrieve the cropped image or handle any errors.
Code Example
let image: UIImage = // The image to be cropped
let cropViewController = TOCropViewController(image: image)
cropViewController.delegate = self // Set the delegate
// Present the crop view controller modally
present(cropViewController, animated: true, completion: nil)
Configuration
Delegate Protocol
To receive cropping completion callbacks, implement the TOCropViewControllerDelegate protocol in your view controller.
class YourViewController: UIViewController, TOCropViewControllerDelegate {
// Implement protocol methods here
}
Customization
To customize the appearance and behavior of TOCropViewController:
- Access the TOCropViewController instance.
- Use the provided properties and methods to customize various aspects, such as colors, aspect ratio, and cropping guidelines.
Further Documentation
For more details, refer to the official documentation and the GitHub repository of TOCropViewController.