Latest 1.3.4
Homepage https://github.com/yurikoles/YKPhotoCircleCrop
License MIT
Platforms ios 8.0
Authors

Version
Platform
Carthage

Language: Swift

License

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

Screenshot 1

Requirements

  • iOS 8.0+
  • Xcode 9+
  • Swift 4

Installation

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

pod 'YKPhotoCircleCrop'

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

github "yurikoles/YKPhotoCircleCrop"

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 YKPhotoCircleCropViewController view controller and pass it the image you want to crop.

let circleCropController = YKCircleCropViewController()
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 YKCircleCropViewControllerDelegate and set the delegate

// Delegate
circleCropController.delegate = self

// MARK: - YKCircleCropViewControllerDelegate
func circleCropDidCancel() {
     print("User canceled the crop flow")
}

func circleCropDidCropImage(_ image: UIImage) {
     imageView.image = image
     print("Image cropped!")
}

Image resize

YKPhotoCircleCrop 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

YKPhotoCircleCrop 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

YKPhotoCircleCrop is based on AAPhotoCircleCrop, which is in turn based on KACircleCropViewController

Author

Yurii Kolesnykov (@yurikoles), [email protected]

License

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

Latest podspec

{
    "name": "YKPhotoCircleCrop",
    "version": "1.3.4",
    "summary": "A simple circular image cropper written in Swift",
    "description": "This is a simple circular image cropper written in Swift which can be used after the user image selection. The user can select the circle they want to user as profile picture.",
    "homepage": "https://github.com/yurikoles/YKPhotoCircleCrop",
    "screenshots": [
        "https://github.com/yurikoles/YKPhotoCircleCrop/raw/master/Resources/screenshot1.png",
        "https://github.com/yurikoles/YKPhotoCircleCrop/raw/master/Resources/screenshot2.png"
    ],
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Yurii Kolesnykov": "[email protected]"
    },
    "source": {
        "git": "https://github.com/yurikoles/YKPhotoCircleCrop.git",
        "tag": "1.3.4"
    },
    "social_media_url": "https://twitter.com/yurikoles",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "YKPhotoCircleCrop/Classes/**/*"
}

Pin It on Pinterest

Share This