Giter VIP home page Giter VIP logo

igrphototweaks's Introduction

[The Project is not served, please, enjoy forward :)]

U can use Mantis

IGRPhotoTweaks

IGRPhotoTweaks

IGRPhotoTweaks is a swift 4.2 library allow to expand an interface to crop photos, based on PhotoTweaks. It can let user drag, rotate, scale the image, and crop it. You will find it mimics the interaction of Photos.app on iOS 9. :]

Build Status Pod Version Platform License


Contribute to Development Goals Here:

BTC: 16tGJzt4gJJBhBetpV6BuaWuNfxvkdkbt4

BCH: bitcoincash:qpcwefpxddjqzdpcrx6tek3uh6x9v7t8tugu30jvks

LTC: litecoin:MLZxuAdJCaW7LdM4sQuRazgdNvd8G2bdyt


Usage

IGRPhotoTweaksViewController is a base interface for YourPhotoTweaksViewController. IGRPhotoTweaksViewController offers all the operations to crop the photo, which includes translation, rotate and scale.

To use it,

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "showCrop" {

        let yourCropViewController = segue.destination as! YourPhotoTweaksViewController
        yourCropViewController.image = sender as! UIImage
        yourCropViewController.delegate = self;
    }
}

self.cropAction() is the func calls the edit done action.

self.dismissAction() is the func calls the cancel edit action.

self.changedAngel(value: radians) is the func to set rotation angle.

self.setCropAspectRect(aspect: "9:16") is the func to set aspect ratio for crop view.

self.resetAspectRect() is the func resets all previous aspect ratio.

self.resetView() is the func resets all previous actions.

Get the cropped image

extension ViewController: IGRPhotoTweakViewControllerDelegate {
    func photoTweaksController(_ controller: IGRPhotoTweakViewController, didFinishWithCroppedImage croppedImage: UIImage) {
        self.imageView?.image = croppedImage
        _ = controller.navigationController?.popViewController(animated: true)
    }

    func photoTweaksControllerDidCancel(_ controller: IGRPhotoTweakViewController) {
        _ = controller.navigationController?.popViewController(animated: true)
    }
}

Setup IGRPhotoTweaks Controller

override func viewDidLoad() {
    super.viewDidLoad()

    self.isAutoSaveToLibray = true
}

Setup/Control Angle

fileprivate func setupSlider() {
    self.angleSlider?.minimumValue = -Float(IGRRadianAngle.toRadians(45))
    self.angleSlider?.maximumValue = Float(IGRRadianAngle.toRadians(45))
    self.angleSlider?.value = 0.0
}

@IBAction func onChandeAngleSliderValue(_ sender: UISlider) {
    let radians: CGFloat = CGFloat(sender.value)
    self.changeAngle(radians: radians)
}
    

Customize View

override open func setupThemes() {
    IGRCropLine.appearance().backgroundColor = UIColor.green
    IGRCropGridLine.appearance().backgroundColor = UIColor.yellow
    IGRCropCornerView.appearance().backgroundColor = UIColor.purple
    IGRCropCornerLine.appearance().backgroundColor = UIColor.orange
    IGRCropMaskView.appearance().backgroundColor = UIColor.blue
    IGRPhotoContentView.appearance().backgroundColor = UIColor.gray
    IGRPhotoTweakView.appearance().backgroundColor = UIColor.brown
}

override open func customBorderColor() -> UIColor {
    return UIColor.red
}

override open func customBorderWidth() -> CGFloat {
    return 2.0
}

override open func customCornerBorderWidth() -> CGFloat {
    return 4.0
}

override open func customCropLinesCount() -> Int {
    return 3
}

override open func customGridLinesCount() -> Int {
    return 4
}

override open func customCornerBorderLength() -> CGFloat {
    return 30.0
}

override open func customIsHighlightMask() -> Bool {
    return true
}

override open func customHighlightMaskAlphaValue() -> CGFloat {
    return 0.3
}

Example

IGRPhotoTweaks.xcodeproj -> IGRPhotoTweaks target /Example


Installation

IGRPhotoTweaks is available on CocoaPods. Add the follwing to your Podfile:

pod 'IGRPhotoTweaks', '~> 1.0.0'

Alternatively, you can manually drag the IGRPhotoTweaks folder into your Xcode project.


Issues

Not works in Objective-C


Protip

If using with an existing UIImagePickerController, be sure to set allowsEditing = NO otherwise you may force the user to crop with the native editing tool before showing IGRPhotoTweaksViewController.

igrphototweaks's People

Contributors

ikorich avatar climbatize avatar mihirmehtadet avatar ykying avatar levidahl avatar mantergo avatar

Forkers

assassinmt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.