Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVCaptureVideoPreviewLayer doesn't fill up whole iPhone 4S Screen

AVCaptureVideoPreviewLayer *avLayer =                  [AVCaptureVideoPreviewLayer layerWithSession:session]; avLayer.frame = self.view.frame; [self.view.layer addSublayer:avLayer]; 

I use AVCaptureVideoPreviewLayer to display video on the view. But the video's view didn't fill up the full iPhone4's screen.(two grey bar at the right&left side)

I want the video fills up full screen. How can I deal with it? Thank you very much!

enter image description here

like image 491
Rafer Avatar asked Feb 25 '11 13:02

Rafer


1 Answers

Maybe this solves it?

CGRect bounds=view.layer.bounds; avLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; avLayer.bounds=bounds; avLayer.position=CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)); 
like image 195
flitzwald Avatar answered Sep 21 '22 02:09

flitzwald