ios - 如何从 AVCaptureSession captureStillImageAsynchronouslyFromConnection 中删除屏幕 "flash"效果

标签 ios swift avcapturesession

我发现不可能删除 avcapturesession captureStillImageAsynchronouslyFromConnection 附带的快门声音,但我没有看到有人试图删除它附带的那种屏幕闪光。

您拍摄一张照片,屏幕会变亮一秒钟(不是真正的闪光),然后恢复到正常亮度。

Instagram 似乎正在使用 avcapturesession,并且没有屏幕闪烁。

https://developer.apple.com/library/content/samplecode/AVCam/Introduction/Intro.html

我浏览了这个^,这是我在我的应用程序中使用的,但我没有看到它在任何地方被引用。我认为这是我必须弄乱的一些属性(property)?

任何帮助表示赞赏。

最佳答案

首先,您不应该使用拥有 captureStillImageAsynchronouslyFromConnection 方法的 AVCaptureStillImageOutput,因为它已被弃用。请改用 AVCapturePhotoOutput

其次,您引用的 Apple 示例在实现“闪烁”的 CameraViewController.swift 中有以下代码段:

self.previewView.videoPreviewLayer.opacity = 0
UIView.animate(withDuration: 0.25) { [unowned self] in
    self.previewView.videoPreviewLayer.opacity = 1
}

所以只需删除/注释掉它就可以了。

关于ios - 如何从 AVCaptureSession captureStillImageAsynchronouslyFromConnection 中删除屏幕 "flash"效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41646882/

相关文章:

ios - NSString + URLEncoding中的内存泄漏

php - Alamofire 和 PHP 上传图像

ios - AVCaptureVideoDataOutput P3 色彩空间

ios - 更改 AVCaptureDeviceInput 导致 AVAssetWriterStatusFailed

ios - 如何强制-drawViewHierarchyInRect :afterScreenUpdates: to take snapshots at @2x resolution?

ios - 如何使用 POST 请求登录网站? ( swift ,iOS)

ios - 在 alertView if 语句中调用 IBaction

php - iOS 应用程序中的服务器保护

iOS swift : Custom scroll animation for UIScrollView

ios - 在 Swift 中使用 "= {}()"声明类属性的性质是什么?