测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2017年8月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 mingloan 维护。
CaptureCenter 不是一个自定义摄像捕获 UI 库。它提供了一个简单的接口层来连接 AVFoundation 的功能。CaptureCenter 提供了聚焦、调整曝光、应用闪光灯等 AVCaptureDevice 设置的接口。此外,CaptureCenter 在幕后处理照片捕获和视频录制流程。开发者可以使用自己的 UI 组件或图标构建自己的相机 UI,并将 UI 动作与 CaptureCenter 提供的接口映射。
要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install
。
Capture Center 支持 iOS 9.0 或更高版本
CaptureCenter 通过 CocoaPods 可用。要安装它,只需将以下行添加到您的 Podfile 中
pod "CaptureCenter"
或者通过 Carthage
在 Cartfile 中
github "MingLoan/CaptureCenter"
然后运行
carthage update --platform iOS
let captureCenter = CaptureCenter(captureMode: .photo)
目前仅支持 照片 捕获模式,其他模式将很快支持。
public enum CaptureMode {
case photo
// unsupport now
case video(size: VideoSize, location: URL, didStart: () -> (), progress: (CGFloat) -> (), willFinish: () -> (), completion: (AVAsset?) -> ())
// unsupport now
case stream
}
您可以从 CaptureCenter 实例中获取相机预览视图,并将其用作 UIView。
captureCenter.previewView.frame = CGRect(...)
view.addSubview(captureCenter.previewView)
要开始捕获,调用 startCapturingWithDevicePosition,您可以设置设备位置。启用 cameraControlShouldOn 可以启用相机控制,例如轻触对焦、捏合缩放,默认为 false。捕获开始后将调用回调。
captureCenter.startCapturingWithDevicePosition(
.back,
fromVC: self,
cameraControlShouldOn: true) { [weak self] finished in
guard let strongSelf = self else { return }
if finished {
// ...
}
}
要停止捕获,
captureCenter.stopCapturing()
public func captureWithOptions(_ options: ImageOptions, completion: @escaping ((Data?) -> ()))
public func changeCameraWithStartBlock(_ startBlock: (() -> ()), finished endBlock: @escaping ((Bool) -> ()))
public func focusWithMode(_ focusMode: AVCaptureFocusMode, exposureMode: AVCaptureExposureMode, at devicePoint: CGPoint, monitorSubjectAreaChange: Bool, showUI: @escaping ((Bool) -> ()))
public func exposeWithBias(_ exposureBias: CGFloat)
public func setZoomScale(_ scale: CGFloat)
mingloan, [email protected]
CaptureCenter可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。