项目作者: yonat

项目描述 :
Show camera layer as a background to any UIView
高级语言: Swift
项目地址: git://github.com/yonat/CameraBackground.git
创建时间: 2015-12-09T15:10:12Z
项目社区:https://github.com/yonat/CameraBackground

开源协议:MIT License

下载


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

  1. view.addCameraBackground()
  2. // ...
  3. view.takeCameraSnapshot( {
  4. // animate snapshot capture
  5. self.view.alpha = 0
  6. UIView.animate(withDuration: 1) { self.view.alpha = 1 }
  7. },
  8. completion: { (capturedImage, error) -> () in
  9. self.view.freeCameraSnapshot() // unfreeze image
  10. // ... handle capturedImage and error
  11. }
  12. )
  13. // ...
  14. 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:

  1. view.addCameraBackground(
  2. showButtons: true,
  3. buttonMargins: UIEdgeInsets(top: 30, left: 10, bottom: 10, right: 10),
  4. buttonsLocation: .left
  5. )

Installation

CocoaPods:

  1. pod 'CameraBackground'

Swift Package Manager:

  1. dependencies: [
  2. .package(url: "https://github.com/yonat/CameraBackground", from: "1.7.2")
  3. ]

Meta

@yonatsharon

https://github.com/yonat/CameraBackground