ByvImagePicker 0.1.5

ByvImagePicker 0.1.5

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Nov 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Adrian Apodaca.



 
Depends on:
ByvUtils~> 1.1
TOCropViewController= 2.3.4
 

  • By
  • Adrian Apodaca

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, [email protected]

License

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