You need to use the videoGravity property for AVCaptureVideoPreviewLayer .
Take a look at the doc . You need to use: AVLayerVideoGravityResizeAspectFill
Edit:
Based on this, the decision based on the appeal is as follows:
- (void)setSession:(AVCaptureSession *)session { ((AVPlayerLayer *)[self layer]).videoGravity = AVLayerVideoGravityResizeAspectFill; ((AVPlayerLayer *)[self layer]).bounds = ((AVPlayerLayer *)[self layer]).bounds; [(AVCaptureVideoPreviewLayer *)[self layer] setSession:session]; }
dcorbatta
source share