AVCaptureVideoPreviewLayer doesn#39;t fill up whole iPhone 4S Screen(AVCaptureVideoPreviewLayer 没有填满整个 iPhone 4S 屏幕)
本文介绍了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 屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:AVCaptureVideoPreviewLayer 没有填满整个 iPhone 4S 屏幕


猜你喜欢
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- UITextView 内容插图 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- URL编码Swift iOS 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01