Skip to content

Latest commit

 

History

History
86 lines (68 loc) · 2.67 KB

File metadata and controls

86 lines (68 loc) · 2.67 KB

ByvImagePicker

CI Status Version License Platform

ByvImagePicker is a NSObject class that can present an action sheet to select the UIImagePickerController source type and let edit image with TOCropViewController in 3 different ways.

Usage

To only display picker:

@IBAction func pickImage(_ sender: UIButton) {
    if picker == nil {
        picker = ByvImagePicker()
    }
    let from = ByvFrom(controller: self, from:sender.frame, inView:self.view, arrowDirections:.any)
    picker!.getImage(from: from, completion: { image in
        self.imageView.image = image
    })
}

To pick editable image:

@IBAction func pickAndEdit(_ sender: UIButton) {
    if picker == nil {
        picker = ByvImagePicker()
    }
    let from = ByvFrom(controller: self, from:sender.frame, inView:self.view, arrowDirections:.any)
    picker!.getImage(from: from, editable:true, completion: { image in
        self.imageView.image = image
    })
}

To pick an Image with forced aspect ratio:

@IBAction func pickAndCrop(_ sender: UIButton) {
    if picker == nil {
        picker = ByvImagePicker()
    }
    let from = ByvFrom(controller: self, from:sender.frame, inView:self.view, arrowDirections:.any)
    picker!.getFixedImage(from: from, customAspectRatio: imageView.bounds.size, completion: { image in
        self.imageView.image = image
    })
}

To pick a circular image:

@IBAction func pickProfile(_ sender: UIButton) {
    if picker == nil {
        picker = ByvImagePicker()
    }
    let from = ByvFrom(controller: self, from:sender.frame, inView:self.view, arrowDirections:.any)
    picker!.getCircularImage(from: from, completion: { image in
        self.profileImage.image = image
    })
}

Example

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

Requirements

Installation

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

pod "ByvImagePicker"

Author

Adrian Apodaca, adrian@byvapps.com

License

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