How can I implement a code for screen recording a uiview which have camera preview layer in iOS objective c?

I am using ios objective c language to design an ios app. I am trying to implement a code for screen recording a uiview having CameraPreviewLayer. In the code, I am unable to capture the camerapreviewlayer it shows the Black screen where I implemented the CameraPreviewLayer capturing all other subviews.