![Platform](https://camo.githubusercontent.com/b63346f957d5cc160d474324106772739e29a19b550ea935fa9826dd49e43104/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506c6174666f726d2d253230694f532532302d626c75652e737667)
- IRCameraViewController is a powerful camera view controller for iOS.
- Completely custom camera with AVFoundation
- Custom view with camera permission denied
- Custom button colors
- Easy way to access album (camera roll)
- Flash auto, off and on
- Focus
- Front and back camera
- Grid view
- Preview photo view with three filters (fast processing)
- Visual effects like Instagram iOS app
- Custom image filters
- Git clone this project.
- Copy this project into your own project.
- Add the .xcodeproj into you project and link it as embed framework.
- You can remove the
demo
and ScreenShots
folder.
- Add
pod 'IRCameraViewController'
in the Podfile
pod install
#import "IRCameraViewController.h"
@interface IRViewController : UIViewController <IRCameraDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *photoView;
- (IBAction)takePhotoTapped;
@end
@implementation IRViewController
- (IBAction)takePhotoTapped
{
IRCameraNavigationController *navigationController =
[IRCameraNavigationController newWithCameraDelegate:self];
[self presentViewController:navigationController animated:YES completion:nil];
}
#pragma mark - IRCameraDelegate optional
- (void)cameraWillTakePhoto
{
NSLog(@"%s", __PRETTY_FUNCTION__);
}
- (void)cameraDidSavePhotoAtPath:(NSURL *)assetURL
{
// When this method is implemented, an image will be saved on the user's device
NSLog(@"%s album path: %@", __PRETTY_FUNCTION__, assetURL);
}
- (void)cameraDidSavePhotoWithError:(NSError *)error
{
NSLog(@"%s error: %@", __PRETTY_FUNCTION__, error);
}
#pragma mark - IRCameraDelegate required
- (void)cameraDidCancel
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)cameraDidTakePhoto:(UIImage *)image
{
_photoView.image = image;
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)cameraDidSelectAlbumPhoto:(UIImage *)image
{
_photoView.image = image;
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
#import "IRCameraViewController.h"
@interface IRViewController : UIViewController
<UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *photoView;
- (IBAction)chooseExistingPhotoTapped;
@end
@implementation IRViewController
- (IBAction)chooseExistingPhotoTapped
{
UIImagePickerController *pickerController =
[IRAlbum imagePickerControllerWithDelegate:self];
[self presentViewController:pickerController animated:YES completion:nil];
}
#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
_photoView.image = [IRAlbum imageWithMediaInfo:info];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
@implementation IRViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UIColor *tintColor = [UIColor greenColor];
[IRCameraColor setTintColor:tintColor];
}
@end
Option |
Type |
Default |
Description |
kIRCameraOptionHiddenToggleButton |
NSNumber (YES/NO) |
NO |
Displays or hides the button that switches between the front and rear camera |
kIRCameraOptionHiddenAlbumButton |
NSNumber (YES/NO) |
NO |
Displays or hides the button that allows the user to select a photo from their album |
kIRCameraOptionHiddenFilterButton |
NSNumber (YES/NO) |
NO |
Displays or hides the button that allos the user to filter their photo |
kIRCameraOptionSaveImageToAlbum |
NSNumber (YES/NO) |
NO |
Save or not the photo in the camera roll |
kIRCameraOptionUseOriginalAspect |
NSNumber (YES/NO) |
NO |
Use the original aspect instead of cropping the image to a square |
#import "IRCamera.h"
@implementation UIViewController
- (void)viewDidLoad
{
//...
[IRCamera setOption:kIRCameraOptionHiddenToggleButton value:@YES];
[IRCamera setOption:kIRCameraOptionHiddenAlbumButton value:@YES];
[IRCamera setOption:kIRCameraOptionHiddenFilterButton value:@YES];
[IRCamera setOption:kIRCameraOptionSaveImageToAlbum value:@YES];
//...
}
- (IBAction)buttonTapped
{
//...
BOOL hiddenToggleButton = [[IRCamera getOption:kIRCameraOptionHiddenToggleButton] boolValue];
BOOL hiddenAlbumButton = [[IRCamera getOption:kIRCameraOptionHiddenAlbumButton] boolValue];
BOOL hiddenFilterButton = [[IRCamera getOption:kIRCameraOptionHiddenFilterButton] boolValue];
BOOL saveToDevice = [[IRCamera getOption:kIRCameraOptionSaveImageToAlbum] boolValue];
//...
}
@end
Custom image filters(You can see how GPUImage work in the demo project):
- Return
YES
by customizePhotoProcessingView
in the IRCameraDelegate
to disable the default filters
#pragma mark - IRCameraDelegate
- (BOOL)customizePhotoProcessingView {
return YES;
}
- Deal with the image by your own way:
#import <GPUImage/GPUImage.h>
- (UIImage *)imageWithSketchFilter:(UIImage *)originImage {
GPUImageFilter *imageFilter = [[GPUImageSketchFilter alloc] init];
return [imageFilter imageByFilteringImage:originImage];
}
Demo Main Page |
Camera |
![Demo Main Page](/irons163/IRCameraViewController/raw/master/ScreenShots/demo1.png) |
![Camera](/irons163/IRCameraViewController/raw/master/ScreenShots/demo2.png) |
Camera with Grid View |
Confirm |
![Camera with Grid View](/irons163/IRCameraViewController/raw/master/ScreenShots/demo3.png) |
![Confirm](/irons163/IRCameraViewController/raw/master/ScreenShots/demo4.png) |
Default filters |
Album |
![Default filters](/irons163/IRCameraViewController/raw/master/ScreenShots/demo5.png) |
![Album](/irons163/IRCameraViewController/raw/master/ScreenShots/demo6.png) |
Custom filters |
Update display view |
![Custom filters](/irons163/IRCameraViewController/raw/master/ScreenShots/demo7.png) |
![Update display view](/irons163/IRCameraViewController/raw/master/ScreenShots/demo8.png) |