ALCameraViewController
A camera view controller with custom image picker and image cropping.
Features
- [x] Front facing and rear facing camera
- [x] Simple and clean look
- [x] Custom image picker with permission checking
- [x] Image cropping
- [x] Flash light
- [x] Zoom
- [x] Tap to focus
Installation & Requirements
This project requires Xcode 9 to run and compiles with swift 4
Note: This library makes use of the AVFoundation camera API's which are unavailable on the iOS simulator. You'll need a real device to run it.
CocoaPods:
Add the following to your Podfile:
For swift 3.2 support
Carthage:
Privacy (iOS 10)
If you are building your app with iOS 10 or newer, you need to add two privacy keys to your app to allow the usage of the camera and photo library, or your app will crash.
Add the keys below to your Info.plist
, adding strings with the description you want to provide when prompting the user.
NSPhotoLibraryUsageDescription
NSCameraUsageDescription
Usage
To use this component couldn't be simpler.
Add import ALCameraViewController
to the top of your controller file.
In the viewController
Parameters
There are a number of configurable options available for CameraViewController
The Cropping Parameters struct accepts the following parameters
The success parameter returns a UIImage?
and a PHAsset?
for more advanced use cases.
If the user canceled photo capture then both of these options will be nil
Note: To prevent retain cycles, it is best to use a
[weak self]
reference within the success parameter
Other usage options
You can also instantiate the image picker component by itself as well.
For more control you can create it directly.
Note: This approach requires some familiarity with the PhotoKit library provided by apple