请帮助我如何更改 AVCaptureVideoPreviewLayer 帧大小和
我路过Height =100px ; and width = 300px
。
如果我通过高度大小 100 而不是宽度不会更改为 300px
这是代码:
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session];
previewLayer.frame = CGRectMake(20, 50, 300, 100);
self.view.frame=CGRectMake(20, 50, 300, 100);
CGRect layerRect = [[[self view] layer] bounds];
[previewLayer setBounds:layerRect];
[previewLayer setPosition:CGPointMake(CGRectGetMidX(layerRect),CGRectGetMidY(layerRect))];
[[[self view] layer] addSublayer:previewLayer];
[previewView.layer addSublayer:previewLayer];