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

Overview

🚨 Warning

This repository is DEPRECATED and not maintained anymore.


Custom camera with AVFoundation. Beautiful, light and easy to integrate with iOS projects. Compatible with Objective-C and Swift.

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

Requirements: iOS 8 or higher.

Who uses 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 by running:

pod install

Alternatively, you can download the latest code version directly and import the files to your project.

Privacy (iOS 10)

If you are building your app with iOS 10 or newer, you need to add two privacy keys to your app's Info.plist to allow the usage of the camera and photo library, or your app will crash.

Add the keys below to the <dict> tag of your Info.plist, replacing the strings with the description you want to provide when prompting the user:

	<key>NSPhotoLibraryUsageDescription</key>
	<string>Enable Photos access to import photos from your library.</string>
	<key>NSCameraUsageDescription</key>
	<string>Enable Camera to take photos.</string>

Usage

Here are some usage examples with Objective-C. You can find example projects for Objective-C and Swift 3 cloning the project. Refer to version 2.2.5 if you need a Swift 2.3 example.

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 their album
kTGCameraOptionHiddenFilterButton NSNumber (YES/NO) NO Displays or hides the button that allos the user to filter their photo
kTGCameraOptionSaveImageToAlbum NSNumber (YES/NO) NO Save or not the photo in the camera roll
kTGCameraOptionUseOriginalAspect NSNumber (YES/NO) NO Use the original aspect instead of cropping the image to a square
#import "TGCamera.h"

@implementation UIViewController

- (void)viewDidLoad
{
    //...
    [TGCamera setOption:kTGCameraOptionHiddenToggleButton value:@YES];
    [TGCamera setOption:kTGCameraOptionHiddenAlbumButton value:@YES];
    [TGCamera setOption:kTGCameraOptionHiddenFilterButton value:@YES];
    [TGCamera setOption:kTGCameraOptionSaveImageToAlbum value:@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 8.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.

To do

  • 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.

Comments
  • Set tintColor for Camera button issue in ios 9

    Set tintColor for Camera button issue in ios 9

    I just tested the code in ios 9 and found that the tint color which has been set to camera shot button doesnt appear It seems to be an ios 9 issue since the same code works on ios 8 and prior,not sure though but still I would like you to please help me figure out the exact reason

    opened by intersilindia 15
  • use_frameworks! broke camera

    use_frameworks! broke camera

    I recently had to start using frameworks for cocoa pods, but when I added the use_frameworks! keyword to the Podfile, the camera now just shows a black screen with no errors or warnings. I tried making sure the project was set to build for iPhone instead of general (a fix for a similar issue), but to no avail.

    bug 
    opened by Phillip3 14
  • Allow for custom colors!

    Allow for custom colors!

    Don't feel obligated to merge this, but I wrote the code so I figured I'd share it if anyone else wants to use it. It's fairly clean, but it's definitely not a perfect solution. I attempted to leave as little footprint as possible, so I left all of the images the same color and changed each button's renderingMode to UIImageRenderingModeAlwaysTemplate to take on the tintColor of the button.

    Detailed summary of changes

    • Removed + (UIColor *)orangeColor and replaced it with + (UIColor *)tintColor in TGCameraColor.m
    • Exposed + (UIColor *)tintColor and + (void)setTintColor:(UIColor*)tintColor in TGCameraColor.h
    • Created TGTintedButton class which tints the images and backgroundImages using [TGCameraColor tintColor], assuming customTintColorOverride has not been set.
    • Created TGTintedLabel which sets the text color to [TGCameraColor tintColor]
    • Changed the UIButtons in the xibs to TGTintedButtons
    • Changed the UILabels in TGCameraAuthorizationViewController.xib to TGTintedLabels
    • Deleted CameraConfirm.imageset and changed the image of the confirm button to CameraShot1
    • Created CameraCheckMark.imageset and created a UIImageView that sits above the confirm button in TGPhotoViewController.xib and added the appropriate constraints1
    • Added TintColorFromAVCaptureFlashMode and set customTintColorOverride of the flash to be gray when it is "off", and the default tint color when it is "on" or "auto".
    • Set the tintColor in TGInitialViewController.m

    Usage

    Call this method before creating the TGCameraNavigationController. You can call it after, but you have to make sure to invalidate all of the tintable buttons and labels.

    [TGCameraColor setTintColor: [UIColor greenColor]];
    

    Screenshots

    image image image image

    Footnotes

    [1] - The image tinting mechanism works by setting the image's renderingMode to UIImageRenderingModeAlwaysTemplate. This changes anything in the image that isn't transparent to the tint color. Since CameraConfirm.imageset has a white checkmark (not transparent), when the image gets tinted it looks the exact same as CameraShot.imageset. To get around this, I put the checkmark on a transparent background (CameraCheckMark.imageset), set the confirm button's image to CameraShot.imageset, and placed an image view with the check mark centered on the button. This has the caveat that the checkmark does not dim when the button is selected. This obviously isn't ideal, but it works well enough :)

    Feel free to respond with any questions / suggestions.

    enhancement 
    opened by miketsprague 12
  • Cannot get the image without using [TGCamera setOption:kTGCameraOptionSaveImageToAlbum value:[NSNumber numberWithBool:YES]];

    Cannot get the image without using [TGCamera setOption:kTGCameraOptionSaveImageToAlbum value:[NSNumber numberWithBool:YES]];

    I created a demo project here (https://github.com/confile/TGCameraViewControllerTest) to show this problem. Only if I set:

    [TGCamera setOption:kTGCameraOptionSaveImageToAlbum value:[NSNumber numberWithBool:YES]];
    

    in my init method I get the images correctly returned from the TGCameraViewController. Without setting the above line there will be no image returned.

    I hope that my sample project helps. You just have to look at BCamera.m. I modified the TGCameraViewController.m and marked the modified parts. The modification is just to skip the screen with the filters after the image has been captured.

    Do you have any idea how I get the image captured or retrieved from the album without using the above line?

    question 
    opened by confile 12
  • Couldn't Run on Device

    Couldn't Run on Device

    I tried to run the example app on iPad and iPhone (both have iOS 8.1.1). But after i tap the 'Take photo' button, the black screen appears and the camera doesn't start. Any help?

    question 
    opened by deviggner 10
  • takePhotoTapped not working

    takePhotoTapped not working

    Hi, I'm trying the updated version of TGCamera as camera icon UI was not showing up for iPhone 5 previously. I manually added the updated Classes folder under TGCameraViewController, but it appears that func takePhotoTapped: doesn't work anymore when TGCameraNavigationController is supposed to be presented. Any ideas? Your help would be much appreciated. Thank you!

    opened by zoufishanmehdi 9
  • Resources (Images) are missing when running on release mode

    Resources (Images) are missing when running on release mode

    So this is the first using this library. A few beta testers (Testflight) told me that the CameraViewController had no buttons or any controls. When I build and deploy it with xcode on Debug mode theres no issue... But if I run it on release mode few Images are missing like in the image below!

    I tried to search about general xcassets issue but theres none. Can you give any hint where the problem may be?

    Camera

    opened by SaifAlDilaimi 9
  • Orientation of taken photo is sometime wrong.

    Orientation of taken photo is sometime wrong.

    I am working on the square branch of your project. As you can see. The orientation of the image is wrong after taking the photo (not from album). This appear nearly 1 out of 10 captures. I do not know why because most of the time the orientation is correct.

    foto 29 11 14 16 19 15

    bug 
    opened by confile 9
  • Photo library button not visible for iPhone 7/iOS 10.2

    Photo library button not visible for iPhone 7/iOS 10.2

    Hi, I noticed the photo library button (on the bottom right) to use a previously taken picture from the photo library is no longer visible for iPhone 7 and iOS 10.2. This wasn't an issue with iPhone 6S using iOS 10.1. Any ideas?

    opened by zoufishanmehdi 8
  • Remove

    Remove "square" cropping

    Hi, I might just be completely stupid but everywhere people are referring to the "square" branch of this project. But I can only see one branch and that one is locked to square size, both when taking a picture and selecting a picture. Is there a branch that can be used as a normal camera?

    Thanks in advance!

    question 
    opened by woobione 7
  • Adding didCancelCamera delegate method.

    Adding didCancelCamera delegate method.

    I updated the demo to just log "didCancelCamera" when that method is called. I'm experimenting with this and needed the delegate to know when the "x" was tapped.

    Thanks for putting this together. I may make another couple of PRs in the coming days as I play with it if that's cool.

    enhancement 
    opened by adamtootle 7
  • Select full image from photo gallery

    Select full image from photo gallery

    Hi, I'm able to use original aspect to capture the full image as you can see in the code below. However, it doesn't apply to photo gallery when I click on it to select a picture from the gallery. As you can see in the screenshot below, the image from photo gallery still appears to be a square. How can I fix this? Really appreciate any input.

    @IBAction func takePhotoTapped(_ sender: AnyObject) { let navigationController = TGCameraNavigationController.new(with: self) TGCamera.setOption("kTGCameraOptionUseOriginalAspect", value: true) self.present(navigationController!, animated: true, completion: nil) }

    screen shot 2019-01-25 at 4 07 48 pm

    screen shot 2019-01-25 at 4 00 51 pm

    opened by zoufishanmehdi 0
  • Cropping Photo Library image move rect upward

    Cropping Photo Library image move rect upward

    When we crop an image picked from Photo Library it cuts a little bit of image from bottom and moves the rect a llittle bit upward. See the attached image for better understanding.

    https://i.imgur.com/3a83o1W.png https://i.imgur.com/hy8RW3g.png

    https://i.imgur.com/1zQSc0K.png https://i.imgur.com/pvQDdbM.png

    opened by mohdirfansaleem 0
  • How to pass value from viewcontroller to cameraview controller

    How to pass value from viewcontroller to cameraview controller

    I add pod file and its working fine. But My problem is that I add one Title label one cameraView and every time this Title label value will be changed. I try to pass the value from view controller to tgcameraviewcontroller but always value is null .how to solve it.please help me .

    TGCameraNavigationController *navigationController = [TGCameraNavigationController newWithCameraDelegate:self]; navigationController.titleLab= @"Hello"; [self presentViewController:navigationController animated:YES completion:nil];

    this is I wrote, cameraView open but that title label is null. please help me

    opened by prasenraj 0
  • Black screen comes up when I click on camera button every once in a while

    Black screen comes up when I click on camera button every once in a while

    Hi, I'm using TGCameraViewController cocoapod for my project. It works fine for the most part but sometimes black screen comes up when I click on camera button. I know a similar issue related to black screen was reported before and the suggested solution was to copy all resources. I checked my project and it already includes everything from the resources folder i.e. TGCameraViewController.bundle. Any idea how to fix this? Thank you!

    opened by zoufishanmehdi 0
Releases(2.2.8)
Owner
Tudo Gostoso Internet
Working with and contributing to the open source community
Tudo Gostoso Internet
Camera engine for iOS, written in Swift, above AVFoundation. :monkey:

?? The most advanced Camera framework in Swift ?? CameraEngine is an iOS camera engine library that allows easy integration of special capture feature

Remi ROBERT 575 Dec 25, 2022
A camera app we will dive deep into AVFoundation library

Camera App In this project you are going to discover few concepts in Swift that I've been working on for few weeks, Core Animations with CAShape Layer

Dheeraj Kumar Sharma 12 Nov 13, 2022
A light weight & simple & easy camera for iOS by Swift.

DKCamera Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so the screen-

Bannings 86 Aug 18, 2022
BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience.

Description BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience. Barco

HyperRedink 1.6k Jan 7, 2023
Library for iOS Camera API. CameraKit helps you add reliable camera to your app quickly.

CameraKit helps you add reliable camera to your app quickly. Our open source camera platform provides consistent capture results, service that scales, and endless camera possibilities.

CameraKit 628 Dec 27, 2022
ALCameraViewController - A camera view controller with custom image picker and image cropping.

ALCameraViewController A camera view controller with custom image picker and image cropping. Features Front facing and rear facing camera Simple and c

Alex Littlejohn 2k Dec 6, 2022
Simple Swift class to provide all the configurations you need to create custom camera view in your app

Camera Manager This is a simple Swift class to provide all the configurations you need to create custom camera view in your app. It follows orientatio

Imaginary Cloud 1.3k Dec 29, 2022
NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS

NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS. Integration can optionally leverage AVFoundation or ARKit.

NextLevel 2k Jan 2, 2023
Fasttt and easy camera framework for iOS with customizable filters

FastttCamera is a wrapper around AVFoundation that allows you to build your own powerful custom camera app without all the headaches of using AVFounda

IFTTT 1.8k Dec 10, 2022
An iOS framework that uses the front camera, detects your face and takes a selfie.

TakeASelfie An iOS framework that uses the front camera, detects your face and takes a selfie. This api opens the front camera and draws an green oval

Abdullah Selek 37 Jan 3, 2023
Video and photo camera for iOS

Features: Description Records video ?? takes photos ?? Flash on/off ⚡ Front / Back camera ↕️ Hold to record video ✊ Tap to take photo ?? Tap to focus

André J 192 Dec 17, 2022
Instagram-like photo browser and a camera feature with a few line of code in Swift.

Fusuma is a Swift library that provides an Instagram-like photo browser with a camera feature using only a few lines of code.

Yuta Akizuki 2.4k Dec 31, 2022
This plugin defines a global navigator.camera object, which provides an API for taking pictures and for choosing images from the system's image library.

title description Camera Take pictures with the device camera. AppVeyor Travis CI cordova-plugin-camera This plugin defines a global navigator.camera

null 0 Nov 2, 2021
A camera designed in Swift for easily integrating CoreML models - as well as image streaming, QR/Barcode detection, and many other features

Would you like to use a fully-functional camera in an iOS application in seconds? Would you like to do CoreML image recognition in just a few more sec

David Okun 868 Dec 29, 2022
iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing

SCRecorder A Vine/Instagram like audio/video recorder and filter framework in Objective-C. In short, here is a short list of the cool things you can d

Simon Corsin 3.1k Dec 25, 2022
A simple, customizable camera control - video recorder for iOS.

LLSimpleCamera: A simple customizable camera - video recorder control LLSimpleCamera is a library for creating a customized camera - video recorder sc

Ömer Faruk Gül 1.2k Dec 12, 2022
A Snapchat Inspired iOS Camera Framework written in Swift

Overview SwiftyCam is a a simple, Snapchat-style iOS Camera framework for easy photo and video capture. SwiftyCam allows users to capture both photos

Andrew Walz 2k Dec 21, 2022
UIView+CameraBackground - Show camera layer as a background to any UIView.

UIView+CameraBackground Show camera layer as a background to any UIView. Features Both front and back camera supported. Flash modes: auto, on, off. Co

Yonat Sharon 63 Nov 15, 2022
Mock UIImagePickerController for testing camera based UI in simulator

Mock UIImagePickerController to simulate the camera in iOS simulator.

Yonat Sharon 18 Aug 18, 2022