iphone 4s中的AvCapture Session全屏

ank*_*rck 3 iphone ios avcapturesession

我正在使用AvCapture会话在相机屏幕上添加cutom叠加.我添加了一个AvCaptureVidePreview图层

AvCaptureVideoPreviewLayer*layer = [[AvCaptureVideoPreviewLayer alloc] iniWithSession:session];
layer.frame = self.view.layer.bounds;
Run Code Online (Sandbox Code Playgroud)

但在iPhone 4S的情况下,相机预览不是全屏.它在iPhone 5中运行良好.

小智 5

CGRect bounds=view.layer.bounds;
layer.videoGravity = AVLayerVideoGravityResizeAspectFill;
layer.bounds=bounds;
layer.position=CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
Run Code Online (Sandbox Code Playgroud)

可能它可以帮助你..