Please help me how to change the AVCaptureVideoPreviewLayer frame size and
I am passing Height =100px ; and width = 300px
.
if i pass the height size 100 than width not change to 300px
Here is code :
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];
@property (nonatomic, retain) AVCaptureVideoPreviewLayer *prevLayer;
Then:
self.prevLayer = [AVCaptureVideoPreviewLayer layerWithSession: self.captureSession];
self.prevLayer.frame = yourRect;
[self.view.layer addSublayer: self.prevLayer];
Thats it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With