DKCamera - 一个采用Swift开发的轻量级简单和轻松的相机框架

网友投稿 1056 2022-11-04

DKCamera - 一个采用Swift开发的轻量级简单和轻松的相机框架

DKCamera - 一个采用Swift开发的轻量级简单和轻松的相机框架

DKCamera

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 9Swift 3.2 & 4.2

Installation

Swift Package Manager

In progress

SPM only support source code, which means it cannot include resources such as images.

iOS 8 and newer

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

# For latest release in cocoapodspod '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 = trueopen var defaultCaptureDevice = DKCameraDeviceSourceType.rear/// Photos will be tagged with the location where they are taken./// Must add the "Privacy - Location XXX" tag to your Info.plist.open var containsGPSInMetadata = false/// 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.swiftpublic 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.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Gorums一个框架,用于简化容错基于quorum协议的设计和实现
下一篇:CMockery 是 Google 发布的用于 C 单元测试的一个轻量级的框架
相关文章

 发表评论

暂时没有评论,来抢沙发吧~