从AVCaptureSession中删除顶部和底部灰色条

时间:2015-07-07 10:00:19

标签: ios avcapturesession

我正在使用AVCaptureSession来录制视频。我想在全屏幕上打开相机,但顶部和底部都显示灰色条。我正在使用以下代码 -

-(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];

}

1 个答案:

答案 0 :(得分:0)

我只是更改captureVideoPreviewLayer的画面,相机全屏显示。