Home

Awesome

UIView+CameraBackground

Show camera layer as a background to any UIView.

Swift Version Build Status License CocoaPods Compatible
Platform PRs Welcome

Features

<p align="center"> <img src="screenshots/focus.png"> &nbsp; <img src="screenshots/countdown.png"> </p>

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 versionCameraBackground version
4.0 (Xcode 9.4)pod 'MiniLayout', '~> 1.2.1'<br>pod 'MultiToggleButton', '~> 1.7.1'<br>pod 'CameraBackground', '~> 1.4.1'
3pod 'MiniLayout', '~> 1.1.0'<br>pod 'MultiToggleButton', '~> 1.5.2'<br>pod 'CameraBackground', '~> 1.2'
2.3pod 'MiniLayout', '~> 1.0.1'<br>pod 'MultiToggleButton', '~> 1.4.0'<br>pod 'CameraBackground', '~> 1.0.2'

Swift Package Manager:

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

Meta

@yonatsharon

https://github.com/yonat/CameraBackground