Latest 1.0
Homepage https://github.com/EngrAhsanAli/AACameraView
License MIT
Platforms ios 8.0
Authors

Table of Contents

Swift 4.0 Carthage compatible CocoaPods License MIT Build Status
License MIT [CocoaPods]()

Description

AACameraView is a lightweight, easy-to-use and customizable camera view framework, written in Swift. It uses AVFoundation framework and construct a camera view with basic options.

Demonstration

You can make AACameraView with simple UIView in your storyboard.

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 8.0+
  • Xcode 8.0+
  • Swift 3+

Installation

AACameraView can be installed using CocoaPods, Carthage, or manually.

CocoaPods

AACameraView is available through CocoaPods. To install CocoaPods, run:

$ gem install cocoapods

Then create a Podfile with the following contents:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
// Swift 3.2+ Compatibility
pod 'AACameraView'
// Swift 4 Compatibility
pod 'AACameraView', '~> 1.0'
end

Finally, run the following command to install it:

$ pod install

Carthage

To install Carthage, run (using Homebrew):

$ brew update
$ brew install carthage

Then add the following line to your Cartfile:

github "EngrAhsanAli/AACameraView" "master"

Then import the library in all files where you use it:

import AACameraView

Manual Installation

If you prefer not to use either of the above mentioned dependency managers, you can integrate AACameraView into your project manually by adding the files contained in the Classes folder to your project.

Getting Started


Create object of camera view

Drag UIView object from the Object Library into your UIViewController in storyboard.

Set view object as camera view

Set the view’s class to AACameraView in the Identity Inspector.
Make sure the module property is also set to AACameraView.

Set properties and usage

Here’s the basic usage and declaration of AACameraView.

Usage:

// IBOutlet for AACameraView
@IBOutlet weak var cameraView: AACameraView!

// Start capture session in viewWillAppear
override func viewWillAppear(_ animated: Bool) {
cameraView.startSession()
}
// Stop capture session in viewWillDisappear
override func viewWillDisappear(_ animated: Bool) {
cameraView.stopSession()
}

// Get response!
cameraView.response = { response in
if let url = response as? URL {
// Recorded video URL here
}
else if let img = response as? UIImage {
// Capture image here
}
else if let error = response as? Error {
// Handle error if any!
}
}

Properties with description

You can use following properties for AACameraView:

Properties Types Description
zoomEnabled Bool Enables zoom by gesture in AACameraView
focusEnabled Bool Enables focus by gesture in AACameraView
cameraPosition AVCaptureDevicePosition Camera device position: front, back
flashMode AVCaptureFlashMode Flash light mode: on, off, auto
outputMode OUTPUT_MODE Camera Mode: image, videoAudio, video
quality OUTPUT_QUALITY Camera Quality: low, medium, high
recordedDuration CMTime Time for recorded video
recordedFileSize Int64 Size for recorded video
hasFlash Bool Check if Flash device available
hasFrontCamera Bool Check if Front camera device available
status AVAuthorizationStatus Camera Device authorization: authorized

Methods with description

You can use following methods for AACameraView.

Methods Description
startSession Starts the capture session for AACameraView
stopSession Stops the capture session for AACameraView
startVideoRecording Start video recording
stopVideoRecording Stop video recording (response callback)
captureImage Capture image (response callback)
toggleCamera Toggle camera device: front, back
toggleMode Toggle camera mode: image, videoAudio
toggleFlash Toggle flash: on, off
triggerCamera Trigger camera (response callback)
requestAuthorization Request for camera access

Note that the response callback will get data when trigger triggerCamera, captureImage and stopVideoRecording methods.

Contributions & License

AACameraView is available under the MIT license. See the LICENSE file for more info.

Pull requests are welcome! The best contributions will consist of substitutions or configurations for classes/methods known to block the main thread during a typical app lifecycle.

I would love to know if you are using AACameraView in your app, send an email to Engr. Ahsan Ali

Latest podspec

{
    "name": "AACameraView",
    "version": "1.0",
    "summary": "AACameraView is a lightweight, easy-to-use and customizable camera view framework written in Swift.",
    "description": "AACameraView is a lightweight, easy-to-use and customizable camera view framework, written in Swift. It uses AVFoundation framework and construct a camera view with basic options.",
    "homepage": "https://github.com/EngrAhsanAli/AACameraView",
    "screenshots": "https://raw.githubusercontent.com/EngrAhsanAli/AACameraView/master/Screenshots/AACameraView.png",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "engrahsanali": "[email protected]"
    },
    "source": {
        "git": "https://github.com/EngrAhsanAli/AACameraView.git",
        "tag": "1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "AACameraView/Classes/**/*"
}

Pin It on Pinterest

Share This