AVCaptureVideoPreviewLayer无法填充边界 [英] AVCaptureVideoPreviewLayer Not Filling Bounds

查看:87
本文介绍了AVCaptureVideoPreviewLayer无法填充边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个AVCaptureVideoPreviewLayer,我想将其填充到UIView的边界.不过,它似乎无法正常工作.它仅显示在屏幕的3/4左右.

I have a AVCaptureVideoPreviewLayer and I want to fill that to the bounds of my UIView. It doesn't seem to be working correctly, though. It only shows on around 3/4 of the screen.

CGRect bounds=self.previewView.layer.bounds;
self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
self.previewLayer.bounds = bounds;
self.previewLayer.position=CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
[self.previewView.layer addSublayer:self.previewLayer];

图片: http://cl.ly/image/1Y441f3B2d1m

推荐答案

添加预览层后,容器视图可能会在某些时候调整大小,并且由于CALayer没有自动调整大小的蒙版或自动布局,它不会更新框架,您需要手动进行

It's likely that your container view get's resized at some point after the preview layer has been added to it, and since CALayer's don't have autoresizing masks or autolayout, it doesn't update it's frame, you'll need to do it manually

这篇关于AVCaptureVideoPreviewLayer无法填充边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆