Giter Site home page Giter Site logo

aaphotocirclecrop's Introduction

AAPhotoCircleCrop

Version Platform Carthage Language: Swift License

AAPhotoCircleCrop is a simple circular photo cropper writter in Swift, based on Whatsapp.

Screenshot 1

Requirements

  • iOS 8.0+
  • Xcode 8.1+
  • Swift 3

Installation

AAPhotoCircleCrop is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AAPhotoCircleCrop'

AAPhotoCircleCrop is available through Carthage. To install it, simply add the following line to your Cartfile:

github "andreaantonioni/AAPhotoCircleCrop"

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

To show the cropper you have just to create a AACricleCropViewController view controller and pass it the image you want to crop.

let circleCropController = AACircleCropViewController()
circleCropController.image = UIImage(named: "my_photo.jpg")!

present(circleCropController, animated: true, completion: nil)

To handle the crop action or the cancel action, you have to implement the protocol AACircleCropViewControllerDelegate and set the delegate

// Delegate
circleCropController.delegate = self

// MARK: - AACircleCropViewControllerDelegate
func circleCropDidCancel() {
     print("User canceled the crop flow")
}
    
func circleCropDidCropImage(_ image: UIImage) {
     imageView.image = image
     print("Image cropped!")
}

Image resize

AAPhotoCircleCrop can resize the cropped image to a specific width and height.

// Set the imageSize you want to get
circleCropController.imageSize = CGSize(width: 200, height: 200)

Localization

AAPhotoCircleCrop support localized strings. To get button titles localized, just sets a value to selectTitle and cancelTitle

// ๐ŸŒŽ use selectTitle and cancelTitle to localize buttons
circleCropController.selectTitle = NSLocalizedString("select-button", comment: "Select")
circleCropController.cancelTitle = NSLocalizedString("cancel-button", comment: "Cancel")

Dependencies

AAPhotoCircleCrop is base on KACircleCropViewController

Author

Andrea Antonioni (@andrea_anto97), [email protected]

License

AAPhotoCircleCrop is available under the MIT license. See the LICENSE file for more info.

aaphotocirclecrop's People

Contributors

andreaantonioni avatar jguffey avatar

Watchers

James Cloos avatar

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.