GithubHelp home page GithubHelp logo

onawhim / dkcamera Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhangao0086/dkcamera

0.0 2.0 0.0 256 KB

A light weight & simple & easy camera for iOS by Swift.

License: MIT License

Ruby 1.59% Objective-C 0.98% Swift 97.43%

dkcamera's Introduction

DKCamera

Build Status Version Status license MIT Carthage compatible


Description

A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so the screen-orientation lock will be ignored(Perfect orientation handling). And it has two other purposes:

  • Can be presenting or pushing or Integrating.
  • Suppressing the warning "Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates."(It seems a bug in iOS 8).
  • Compatible with iOS 11 and iPhone X

Requirements

  • Xcode 9
  • Swift 3.2 & 4

Installation

iOS 8 and newer

DKCamera is available on CocoaPods. Simply add the following line to your podfile:

# For latest release in cocoapods
pod 'DKCamera'

iOS 7.x

Please use the 1.2.11 tag. To use Swift libraries on apps that support iOS 7, you must manually copy the files into your application project. CocoaPods only supports Swift on OS X 10.9 and newer, and iOS 8 and newer.

Easy to use

let camera = DKCamera()

camera.didCancel = {
	print("didCancel")

	self.dismiss(animated: true, completion: nil)
}

camera.didFinishCapturingImage = { (image: UIImage?, metadata: [AnyHashable : Any]?) in
    print("didFinishCapturingImage")
    
    self.dismiss(animated: true, completion: nil)
    
    self.imageView?.image = image
}

self.present(camera, animated: true, completion: nil)

You also can use these APIs:

open var cameraOverlayView: UIView?

/// The flashModel will to be remembered to next use.
open var flashMode:AVCaptureFlashMode!

open class func isAvailable() -> Bool

/// Determines whether or not the rotation is enabled.
open var allowsRotate = false

/// set to NO to hide all standard camera UI. default is YES.
open var showsCameraControls = true

open var defaultCaptureDevice = DKCameraDeviceSourceType.rear

/// Notify the listener of the detected faces in the preview frame.
open var onFaceDetection: ((_ faces: [AVMetadataFaceObject]) -> Void)?

If you are going to add a full-screen view as cameraOverlayView, maybe you should use the DKCameraPassthroughView or its subclass that have overriden the hitTest method in order to the event passes through to the expected view.

//  DKCamera.swift
public class DKCameraPassthroughView: UIView {
	public override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
		let hitTestingView = super.hitTest(point, withEvent: event)
		return hitTestingView == self ? nil : hitTestingView
	}
}

License

DKCamera is released under the MIT license. See LICENSE for details.

dkcamera's People

Contributors

zhangao0086 avatar mktomaszewski avatar blazierkyle avatar readmecritic avatar

Watchers

Michael Gray avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.