I want to implement rounded corners on my RecordingViewController(which has the camera view).I tried going into the app delegate and changing the corner radius of the window however, it seemed to not work. I believe the issue is with this method (AVLayerVideoGravityResizeAspectFill), it seems to fill the entire screen and takes no consideration to changing the window corner radius. Any ideas?
var captureSession:AVCaptureSession?
var videoPreviewLayer:AVCaptureVideoPreviewLayer?
First of all create a UIView and give it corner radius. After that add AVCaptureVideoPreviewLayer as sublayer to that view.
myView.layer.masksToBounds = true
videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
videoPreviewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
videoPreviewLayer?.frame = myView.layer.bounds
myView.layer.addSublayer(videoPreviewLayer!)
Hope this helps.
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