UIView+CameraBackground - Show camera layer as a background to any UIView.

Overview

UIView+CameraBackground

Show camera layer as a background to any UIView.

Swift Version Build Status License CocoaPods Compatible
Platform PRs Welcome

Features

  • Both front and back camera supported.
  • Flash modes: auto, on, off.
  • Countdown timer.
  • Tap to focus.
  • Pinch to zoom.

 

Usage

view.addCameraBackground()
// ...
view.takeCameraSnapshot( {
      // animate snapshot capture
      self.view.alpha = 0
      UIView.animate(withDuration: 1) { self.view.alpha = 1 }
  },
  completion: { (capturedImage, error) -> () in
      self.view.freeCameraSnapshot() // unfreeze image
      // ... handle capturedImage and error
  }
)
// ...
view.removeCameraBackground()

Important: Remember to add NSCameraUsageDescription to your Info.plist.

Layout

You can change the location of the camera controls (flash, timer, and front/back camera selection) or hide them altogether:

view.addCameraBackground(
   showButtons: true,
   buttonMargins: UIEdgeInsets(top: 30, left: 10, bottom: 10, right: 10),
   buttonsLocation: .left
)

Installation

CocoaPods:

pod 'CameraBackground'

Legacy versions:

Swift version CameraBackground version
4.0 (Xcode 9.4) pod 'MiniLayout', '~> 1.2.1'
pod 'MultiToggleButton', '~> 1.7.1'
pod 'CameraBackground', '~> 1.4.1'
3 pod 'MiniLayout', '~> 1.1.0'
pod 'MultiToggleButton', '~> 1.5.2'
pod 'CameraBackground', '~> 1.2'
2.3 pod 'MiniLayout', '~> 1.0.1'
pod 'MultiToggleButton', '~> 1.4.0'
pod 'CameraBackground', '~> 1.0.2'

Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/yonat/CameraBackground", from: "1.6.5")
]

Meta

@yonatsharon

https://github.com/yonat/CameraBackground

You might also like...
Fasttt and easy camera framework for iOS with customizable filters
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

A light weight & simple & easy camera for iOS by Swift.
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-

Camera engine for iOS, written in Swift, above AVFoundation. :monkey:
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

A Snapchat Inspired iOS Camera Framework written in Swift
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

A camera designed in Swift for easily integrating CoreML models - as well as image streaming, QR/Barcode detection, and many other features
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

Mock UIImagePickerController for testing camera based UI in simulator
Mock UIImagePickerController for testing camera based UI in simulator

Mock UIImagePickerController to simulate the camera in iOS simulator.

An iOS framework that uses the front camera, detects your face and takes a selfie.
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

Video and photo camera for iOS
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

ScanBarcodes is a SwiftUI view that scans barcodes using an iPhone or iPad camera.

ScanBarcodes ScanBarcodes is a SwiftUI view that scans barcodes using an iPhone or iPad camera. The framework uses AVFoundation for high performance v

Comments
  • landscape position issue

    landscape position issue

    i used the lib in project and make the camera view controller in middle of project and to open it i used self.navigationController?.pushViewController(VC, animated: true) in landscape position (live stream ) the photo was rotated any help how to fix this?

    opened by RanaAbdou 2
  • Swift Package Manager fails due to Invalid Manifest

    Swift Package Manager fails due to Invalid Manifest

    Version Used: 1.6.6 Note:

    1. I also tried the master branch and Next Major version with same results
    2. Used the XCode interface for adding a package

    Sample Screenshot of the issue:

    Adding package failed bug 
    opened by bordsfast 1
  • AddCameraBackground when device is in landscape, camera preview displays portrait orientation

    AddCameraBackground when device is in landscape, camera preview displays portrait orientation

    Description of the problem: Place the iPhone in landscape orientation. Call addCameraBackground function (position any, show buttons false)

    The camera preview layer is not taking into consideration the device orientation. For properly layout, I have to rotate the device in portrait, and then to landscape again.

    bug 
    opened by nastasiupta 1
  • startRunning should be called from background thread

    startRunning should be called from background thread

    Description of the problem: Display CameraBackground

    class func stillCameraCaptureSession(_ position: AVCaptureDevice.Position) -> AVCaptureSession? { #if targetEnvironment(simulator) return nil #endif let session = AVCaptureSession() session.sessionPreset = AVCaptureSession.Preset.photo session.addCameraInput(position) session.addOutput(AVCaptureStillImageOutput()) session.startRunning() return session }

    -[AVCaptureSession startRunning] should be called from background thread. Calling it on the main thread can lead to UI unresponsiveness

    bug 
    opened by nastasiupta 0
Owner
Yonat Sharon
Freelance iOS developer. Agile, TDD, and all that jazz. 🎸
Yonat Sharon
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
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
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
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
Custom camera with AVFoundation. Beautiful, light and easy to integrate with iOS projects.

?? Warning This repository is DEPRECATED and not maintained anymore. Custom camera with AVFoundation. Beautiful, light and easy to integrate with iOS

Tudo Gostoso Internet 1.4k Dec 16, 2022
A fully customisable and modern camera implementation for iOS made with AVFoundation.

Features Extremely simple and easy to use Controls autofocus & exposure Customizable interface Code-made UI assets that do not lose resolution quality

Gabriel Alvarado 1.3k Nov 30, 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
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
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
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