问题
I have a AVCaptureVideoPreviewLayer and I want to fill that to the bounds of my UIView. It doesn't seem to be working correctly, though. It only shows on around 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:
It's likely that your container view get's resized at some point after the preview layer has been added to it, and since CALayer's don't have autoresizing masks or autolayout, it doesn't update it's frame, you'll need to do it manually
来源:https://stackoverflow.com/questions/27735187/avcapturevideopreviewlayer-not-filling-bounds