AVCaptureVideoPreviewLayer Not Filling Bounds

I have an AVCaptureVideoPreviewLayer and I want to fill it to the limits of my UIView. However, it seems to be working incorrectly. It is displayed only on approximately 3/4 of the screen.

CGRect bounds=self.previewView.layer.bounds; self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; self.previewLayer.bounds = bounds; self.previewLayer.position=CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)); [self.previewView.layer addSublayer:self.previewLayer]; 

Image: http://cl.ly/image/1Y441f3B2d1m

+1
source share
1 answer

Your container preview will probably change at some point after adding the preview layer, and since CALayer does not have automatic masks or autostart, it does not update it, you will need to do it manually

+5
source

Source: https://habr.com/ru/post/979878/


All Articles