从 AVCaptureSession 中移除顶部和底部的灰色条
Remove top and bottom gray bar from AVCaptureSession
我正在使用AVCaptureSession
录制video.I想全屏打开相机但是顶部和底部显示灰色条。我正在使用以下代码-
-(void)addCamera
{
session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetMedium;
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.view.bounds;
[self.view.layer addSublayer:captureVideoPreviewLayer];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
AVCaptureDevicePosition currentCameraPosition = [input device].position;
currentCameraPosition = AVCaptureDevicePositionFront;
if (!input)
{
// Handle the error appropriately.
NSLog(@"ERROR: trying to open camera: %@", error);
}
[session addInput:input];
}
我只是更改 captureVideoPreviewLayer
的框架,相机全屏显示。
我正在使用AVCaptureSession
录制video.I想全屏打开相机但是顶部和底部显示灰色条。我正在使用以下代码-
-(void)addCamera
{
session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetMedium;
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.view.bounds;
[self.view.layer addSublayer:captureVideoPreviewLayer];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
AVCaptureDevicePosition currentCameraPosition = [input device].position;
currentCameraPosition = AVCaptureDevicePositionFront;
if (!input)
{
// Handle the error appropriately.
NSLog(@"ERROR: trying to open camera: %@", error);
}
[session addInput:input];
}
我只是更改 captureVideoPreviewLayer
的框架,相机全屏显示。