Ios iphone 4s中的AvCapture会话全屏

Ios iphone 4s中的AvCapture会话全屏,ios,iphone,avcapturesession,Ios,Iphone,Avcapturesession,我正在开发AvCapture会话,以便在相机屏幕上添加cutom覆盖层。我添加了一个AvCaptureVidePreview层作为 AvCaptureVideoPreviewLayer*layer = [[AvCaptureVideoPreviewLayer alloc] iniWithSession:session]; layer.frame = self.view.layer.bounds; 但iPhone 4S的摄像头预览并非全屏。它在iPhone5中运行良好 CGRect bounds

我正在开发AvCapture会话,以便在相机屏幕上添加cutom覆盖层。我添加了一个AvCaptureVidePreview层作为

AvCaptureVideoPreviewLayer*layer = [[AvCaptureVideoPreviewLayer alloc] iniWithSession:session];
layer.frame = self.view.layer.bounds;
但iPhone 4S的摄像头预览并非全屏。它在iPhone5中运行良好

CGRect bounds=view.layer.bounds;
layer.videoGravity = AVLayerVideoGravityResizeAspectFill;
layer.bounds=bounds;
layer.position=CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
也许它能帮助你