Table of Contents
AAImagePicker
Description
AAImagePicker is a simple & easy-to-use image picker designed to present both camera and photo library options and get the UIImage easily.
Demonstration
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
- iOS 8.0+
- Xcode 8.0+
Installation
AAImagePicker
can be installed using CocoaPods, Carthage, or manually.
CocoaPods
AAImagePicker
is available through CocoaPods. To install CocoaPods, run:
$ gem install cocoapods
Then create a Podfile with the following contents:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target '<Your Target Name>' do
pod 'AAImagePicker', '0.1.3'
end
Finally, run the following command to install it:
$ pod install
Carthage
To install Carthage, run (using Homebrew):
$ brew update
$ brew install carthage
Then add the following line to your Cartfile:
github "EngrAhsanAli/AAImagePicker" "master"
Then import the library in all files where you use it:
import AAImagePicker
Manual Installation
If you prefer not to use either of the above mentioned dependency managers, you can integrate AAImagePicker
into your project manually by adding the files contained in the Classes folder to your project.
Getting Started
##Get authorized to use AAImagePicker!
You need to add the following in your Info.plist
file.
<!-- Photo Library -->
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) photo use</string>
<!-- Camera -->
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) camera use</string>
Create instance of image picker
Create an instance by just calling the following line in your view controller.
let imagePicker = AAImagePicker()
Show image picker options
Show image picker options by just calling the following method
imagePicker.present { (image) in
// Get your image
}
Note that this method has optional parameter
AAImagePickerOptions
Here's the method signature:
open func present(_ options: AAImagePickerOptions? = nil, _ completion: @escaping ((UIImage) -> Void))
Define options
You can define options in your code and pass the options to present
function.
actionSheetTitle: String = "Choose Option"
actionSheetMessage: String = "Select an option to pick an image"
optionCamera = "Camera"
optionLibrary = "Photo Library"
optionCancel = "Cancel"
allowsEditing = false
rotateCameraImage: CGFloat = 0
resizeValue: CGFloat = 500
resizeType: AAResizer = .none
Note that
resizeValue
will depend on the method fromresizeType
.
Use AAResizer to get the resized image
By defualt, it has .none
but you can change it if you want.
Resizing options are .width
and .scale
.
You can pass resizeType
to AAImagePickerOptions
and set the value by setting resizeValue
.
Contributions & License
AAImagePicker
is available under the MIT license. See the LICENSE file for more info.
Pull requests are welcome! The best contributions will consist of substitutions or configurations for classes/methods known to block the main thread during a typical app lifecycle.
I would love to know if you are using AAImagePicker
in your app, send an email to Engr. Ahsan Ali