Latest 0.27
Homepage https://github.com/guoyingtao/Mantis
License MIT
Platforms ios 11.0
Authors

Mantis

swift 4.2 badgeplatform iOS badgelicense MIT badge

Mantis is a swift 4.2 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.

MantisMantisMantisMantisMantisMantis

Credits

The crop and rotation feature are strongly inspired by TOCropViewController and IGRPhotoTweaks.

The rotation dial is inspired by 10clock

Requirements

  • iOS 11.0+
  • Xcode 10.0+

Install

CocoaPods

pod 'Mantis', '~> 0.27'

You may also need the code below in your pod file if compile errors happen because of different swift version.

post_install do |installer|
    installer.pods_project.targets.each do |target|
      if ['Mantis'].include? target.name
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '4.2'
        end
      end
    end
  end

Usage

  • Create a cropViewController in Mantis with default config and default mode
let cropViewController = Mantis.cropViewController(image: <Your Image>)
  • The caller needs to conform CropViewControllerProtocal

    public protocol CropViewControllerProtocal: class {
    func didGetCroppedImage(image: UIImage)
    }
  • CropViewController has two modes:

    • normal mode

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

    Mantis

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

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

Mantis

let cropViewController = Mantis.cropViewController(image: <Your Image>, mode = .customizable)
  • Add your own ratio

            let config = MantisConfig()
            config.addCustomRatio(byWidth: 2, andHeight: 1)
            <Your ViewController>.config = config
    
            // Or
    
            <Your ViewController> = Mantis.cropViewController(image: <Your Image>, config: config)

Demo code

        let cropViewController = Mantis.cropViewController(image: <Your Image>, mode: .normal)
        cropViewController.delegate = self
        <Your ViewController>.present(cropViewController, animated: true)
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

Latest podspec

{
    "name": "Mantis",
    "version": "0.27",
    "summary": "A swift photo cropping tool which mimics Photo.app",
    "description": "Mantis is a swift photo cropping tool which mimics Photo.app",
    "homepage": "https://github.com/guoyingtao/Mantis",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Yingtao Guo": "[email protected]"
    },
    "social_media_url": "http://twitter.com/guoyingtao",
    "platforms": {
        "ios": "11.0"
    },
    "source": {
        "git": "https://github.com/guoyingtao/Mantis.git",
        "tag": "0.27"
    },
    "source_files": "Mantis/**/*.{h,swift}",
    "resource_bundles": {
        "Resource": [
            "Mantis/**/*.lproj/*.strings"
        ]
    }
}

Pin It on Pinterest

Share This