Coder Social home page Coder Social logo

juanchristensen / tgcameraviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adamtootle/tgcameraviewcontroller

1.0 1.0 0.0 977 KB

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

License: MIT License

Objective-C 99.22% Ruby 0.78%

tgcameraviewcontroller's Introduction

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
  • 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
  • iPhone, iPod and iPad supported

This library can be applied on devices running iOS 7.0+.



Who use it

Find out who uses TGCameraViewController and add your app to the list.



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 "TGCameraViewController.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__);
}

- (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 - TGCameraDelegate 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

Choose photo

#import "TGCameraViewController.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

Change colors

@implementation TGViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIColor *tintColor = [UIColor greenColor];
    [TGCameraColor setTintColor:tintColor];
}

@end

Options

Option Type Default Description
kTGCameraOptionHiddenToggleButton NSNumber (YES/NO) NO Displays or hides the button that switches between the front and rear camera
kTGCameraOptionHiddenAlbumButton NSNumber (YES/NO) NO Displays or hides the button that allows the user to select a photo from his/her album
kTGCameraOptionHiddenFilterButton NSNumber (YES/NO) NO Displays or hides the button that allos the user to filter his/her photo
kTGCameraOptionSaveImageToAlbum NSNumber (YES/NO) NO Save or not the photo in the camera roll
#import "TGCamera.h"

@implementation UIViewController

- (void)viewDidLoad
{
    //...
    [TGCamera setOption:kTGCameraOptionHiddenToggleButton value:[NSNumber numberWithBool:YES]];
    [TGCamera setOption:kTGCameraOptionHiddenAlbumButton value:[NSNumber numberWithBool:YES]];
    [TGCamera setOption:kTGCameraOptionHiddenFilterButton value:[NSNumber numberWithBool:YES]];
    [TGCamera setOption:kTGCameraOptionSaveImageToAlbum value:[NSNumber numberWithBool:YES]];
    //...
}

- (IBAction)buttonTapped
{
    //...
    BOOL hiddenToggleButton = [[TGCamera getOption:kTGCameraOptionHiddenToggleButton] boolValue];
    BOOL hiddenAlbumButton = [[TGCamera getOption:kTGCameraOptionHiddenAlbumButton] boolValue];
    BOOL hiddenFilterButton = [[TGCamera getOption:kTGCameraOptionHiddenFilterButton] boolValue];
    BOOL saveToDevice = [[TGCamera getOption:kTGCameraOptionSaveImageToAlbum] 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

  • Landscape mode support
  • Zoom
  • Image size as global parameter
  • Fast animations
  • Create a custom picker controller
  • Zoom does not work with the camera roll pictures


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.

tgcameraviewcontroller's People

Contributors

adamtootle avatar gmschasiepen avatar kindraywind avatar lynn310 avatar miketsprague avatar pblondin avatar phillip3 avatar tomisacat avatar xhzengaib avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.