Skip to content

Custom camera with AVFoundation. Beautiful, light and easy to integrate with iOS projects.

License

Notifications You must be signed in to change notification settings

adamtootle/TGCameraViewController

Repository files navigation

TGCameraViewController

TGCameraViewController

Custom camera with AVFoundation. Beautiful, light and easy to integrate with iOS projects.

Build Status  License MIT  Cocoapods  Cocoapods  Analytics

  • Completely custom camera with AVFoundation
  • Custom view with camera permission denied
  • 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
  • Zoom with pinch gesture

This library can be applied on all iPhones and iPods running iOS 7.0+.



Adding to your project

CocoaPods is the recommended way to add TGCameraViewController to your project.

  • Add a pod entry for TGCameraViewController to your Podfile:
pod 'TGCameraViewController'
  • Install the pod(s) by running:
pod install

Alternatively you can directly download the latest code version add drag and drop all files at TGCameraViewController folder onto your project.



Usage

Take photo

#import "TGCamera.h"
#import "TGCameraNavigationController.h"

@interface TGViewController : UIViewController <TGCameraDelegate>

@property (strong, nonatomic) IBOutlet UIImageView *photoView;

- (IBAction)takePhotoTapped;

@end



@implementation TGViewController

- (IBAction)takePhotoTapped
{
    TGCameraNavigationController *navigationController =
    [TGCameraNavigationController newWithCameraDelegate:self];

    [self presentViewController:navigationController animated:YES completion:nil];
}

#pragma mark - TGCameraDelegate optional

- (void)cameraWillTakePhoto
{
    NSLog(@"%s", __PRETTY_FUNCTION__);
}

#pragma mark - TGCameraDelegate required

- (void)cameraDidTakePhoto:(UIImage *)image
{
    _photoView.image = image;
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)cameraDidCancel
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end

Choose photo

#import "TGAlbum.h"

@interface TGViewController : UIViewController
<UINavigationControllerDelegate, UIImagePickerControllerDelegate>

@property (strong, nonatomic) IBOutlet UIImageView *photoView;

- (IBAction)chooseExistingPhotoTapped;

@end



@implementation TGViewController

- (IBAction)chooseExistingPhotoTapped
{
    UIImagePickerController *pickerController =
    [TGAlbum imagePickerControllerWithDelegate:self];

    [self presentViewController:pickerController animated:YES completion:nil];
}

#pragma mark - UIImagePickerControllerDelegate

- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    _photoView.image = [TGAlbum imageWithMediaInfo:info];
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end

Options

Option Type Default Description
kTGCameraOptionSaveImageToDevice NSNumber (YES/NO) YES Save or not the photo in the camera roll
#import "TGCamera.h"

@implementation UIViewController

- (void)viewDidLoad
{
    //...
    [TGCamera setOption:kTGCameraOptionSaveImageToDevice value:[NSNumber numberWithBool:YES]];
    //...
}

- (IBAction)buttonTapped
{
    //...
    BOOL saveToDevice = [[TGCamera getOption:kTGCameraOptionSaveImageToDevice] boolValue];
    //...    
}

@end


Requirements

TGCameraViewController works on iOS 7.0+ version and is compatible with ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates:

  • AssetsLibrary.framework
  • AVFoundation.framework
  • CoreImage.framework
  • Foundation.framework
  • MobileCoreServices.framework
  • UIKit.framework

You will need LLVM 3.0 or later in order to build TGCameraViewController.



Todo

  • Customize layout programatically
  • iPad support
  • Add support for more languages
  • Preview when user choose photo


License

This code is distributed under the terms and conditions of the MIT license.



Change-log

A brief summary of each TGCameraViewController release can be found on the releases.

About

Custom camera with AVFoundation. Beautiful, light and easy to integrate with iOS projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages