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.
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
})
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
ByvImagePicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ByvImagePicker"
Adrian Apodaca, adrian@byvapps.com
ByvImagePicker is available under the MIT license. See the LICENSE file for more info.