The code does not work because CALayer's renderInContext does not render content from the camera.
See the following reference:
https://developer.apple.com/library/ios/qa/qa1714/_index.html
As described in the link above, you can:
1) capture the contents of the camera using the related AVFoundation APIs (https://developer.apple.com/library/ios/qa/qa1702/_index.html#//apple_ref/doc/uid/DTS40010192)
2) and then draw the captured image to the graphics context where you rendered your UIKit elements.