我希望我的Session
能够在我的AVCamPreviewLayer
内以aspectFill方式显示。虽然下面的代码就是这样,但它填满了整个屏幕,而不仅仅是预览层连接到故事板上的视图。因此,在更改AVCaptureVideoPreviewLayer
时,我希望以某种方式将previewView
填充到gravity
的界限而不是全屏。
[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] setVideoGravity:AVLayerVideoGravityResizeAspectFill];
我也试过
- (void)setSession:(AVCaptureSession *)session
{
((AVPlayerLayer *)[self layer]).videoGravity = AVLayerVideoGravityResizeAspectFill;
((AVPlayerLayer *)[self layer]).bounds = ((AVPlayerLayer *)[self layer]).bounds;
[(AVCaptureVideoPreviewLayer *)[self layer] setSession:session];
}
**请注意,这确实来自Apple Docs