Mantis

Mantis is a swift 5.0 library that mimics most interactions in the Photos.app on an iOS device. You can use the CropViewController of Mantis with default buttons, or you can add your own buttons under the "customized" mode.

Requirements

  • iOS 11.0+
  • Xcode 10.0+

Install

CocoaPods

pod 'Mantis', '~> 0.28'
Ruby

Usage

  • Create a cropViewController in Mantis with default config and default mode
let cropViewController = Mantis.cropViewController(image: <Your Image>)
Swift
  • The caller needs to conform CropViewControllerProtocal
public protocol CropViewControllerProtocal: class {
    func didGetCroppedImage(image: UIImage)
}
Swift
  • CropViewController has two modes:

    • normal mode

    In normal mode, you can use a set of standard CropViewController photo editing features.

Screen-Shot

let cropViewController = Mantis.cropViewController(image: <Your Image>, mode = .normal)
Swift
  • customizable mode

This mode includes the standard cropping feature, while enabling users to customize other edit features.

customizable

let cropViewController = Mantis.cropViewController(image: <Your Image>, mode = .customizable)
Swift
  • Add your own ratio
            // Add a custom ratio 1:2 for portrait orientation
            let config = MantisConfig()
            config.addCustomRatio(byVerticalWidth: 1, andVerticalHeight: 2)            
            <Your ViewController> = Mantis.cropViewController(image: <Your Image>, config: config)
            
            // Set the ratioOptions of the config if you don't want to keep all default ratios
            let config = MantisConfig() 
            //config.ratioOptions = [.original, .square, .custom]
            config.ratioOptions = [.custom]
            config.addCustomRatio(byVerticalWidth: 1, andVerticalHeight: 2)            
            <Your ViewController> = Mantis.cropViewController(image: <Your Image>, config: config)
Swift

Demo code

        let cropViewController = Mantis.cropViewController(image: <Your Image>, mode: .normal)
        cropViewController.delegate = self
        <Your ViewController>.present(cropViewController, animated: true)
Swift

GitHub

An iOS Image cropping library, which mimics the Photo App written in Swift.Read More

Latest commit to the master branch on 3-26-2025
Download as zip