Latest 1.1.0
Homepage https://github.com/tomw/TWCameraView
License MIT
Platforms ios 10.0, requires ARC
Authors

A simple & easy-to-use iOS camera wrapper, written in Swift 3. Currently supports taking still photos.

Why?

There’s often a lot of boilerplate code required when building a custom camera in iOS. For example, dealing with orientation when taking photos using AVCaptureSession, AVCapturePhotoOutput and AVCaptureVideoPreviewLayer can be painful. This framework aims to do the work for you.

To help simplify the interface, this framework presumes the device has both a front and back camera.

Usage

First, import TWCameraView:

import TWCameraView

Next, initialise the view, set the delegate, and start the preview:

let cameraView = TWCameraView()
cameraView.delegate = self
self.view.addSubview(cameraView)

cameraView.startPreview(requestPermissionIfNeeded: true)

Setting the requestPermissionIfNeeded flag automatically asks the user for camera permission, and starts the preview session if granded. If you pass false, and no permission has been granted, the preview will not start. Remember to set NSCameraUsageDescription in your Info.plist – this will be displayed in the permission alert.

To take a photo, just call capturePhoto():

cameraView.capturePhoto()

or

cameraView.capturePhoto(imageStabilization: true, flashMode: .off)

The delegate callback function cameraViewDidCaptureImage(image: UIImage, cameraView: TWCameraView) will be called with the output UIImage.

Front or back camera?

TWCameraView supports either camera, but default to back. Just set the cameraType setting:

self.cameraView?.cameraType = .front

or

self.cameraView?.cameraType = .back

Licence

The MIT License (MIT)

Latest podspec

{
    "name": "TWCameraView",
    "version": "1.1.0",
    "summary": "Simple & easy-to-use Swift camera view for iOS.",
    "homepage": "https://github.com/tomw/TWCameraView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Tom Weightman": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tomw/TWCameraView.git",
        "tag": "1.1.0"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "TWCameraView/*.swift",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This