Reputation: 5383
I would like to display the camera preview in a square UIView. This is what I am doing :
previewLayer!.connection?.videoOrientation = AVCaptureVideoOrientation.Portrait
mySquareView.layer.addSublayer(previewLayer)
The result is the camera preview automatically resizing to fit entirely in the view.
I want it to fit horizontally and to be cropped vertically.
How to do that ?
Upvotes: 2
Views: 1436
Reputation: 1431
use previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
Upvotes: 3