我初始化一个AVCaptureSession
并像这样预设它:
AVCaptureSession *newCaptureSession = [[AVCaptureSession alloc] init];
if (YES==[newCaptureSession canSetSessionPreset:AVCaptureSessionPresetPhoto]) {
newCaptureSession.sessionPreset = AVCaptureSessionPresetPhoto;
} else {
// Error management
}
然后我设置一个AVCaptureVideoPreviewLayer
:
self.preview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height/*426*/)];
CALayer *previewLayer = preview.layer;
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session];
captureVideoPreviewLayer.frame = previewLayer.frame;
[previewLayer addSublayer:captureVideoPreviewLayer];
captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspect;
我的问题是:
如何获得在屏幕上CGSize
显示所有captureVideoPreviewLayer
图层所需的确切信息?更准确地说,我需要高度AVLayerVideoGravityResizeAspect
来AVCaptureVideoPreviewLayer
适应preview.size
?
我尝试获得合适的 AVCaptureVideoPreviewLayer 大小。
非常感谢您的帮助