本文介绍了AVCaptureVideoPreviewLayer 没有填满整个 iPhone 4S 屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
AVCaptureVideoPreviewLayer *avLayer =
[AVCaptureVideoPreviewLayer layerWithSession:session];
avLayer.frame = self.view.frame;
[self.view.layer addSublayer:avLayer];
我使用 AVCaptureVideoPreviewLayer 在视图上显示视频.但是视频的视图并没有填满整个 iPhone4 的屏幕.(左右两侧的灰色条)
I use AVCaptureVideoPreviewLayer to display video on the view.But the video's view didn't fill up the full iPhone4's screen.(two grey bar at the right&left side)
我希望视频充满全屏.我该如何处理?非常感谢!
I want the video fills up full screen.How can I deal with it? Thank you very much!
推荐答案
这样可以解决吗?
CGRect bounds=view.layer.bounds;
avLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
avLayer.bounds=bounds;
avLayer.position=CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
这篇关于AVCaptureVideoPreviewLayer 没有填满整个 iPhone 4S 屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!