I have read and gone over: UIImage from CALayer - iPhone SDK
But when I try to use UIGraphicsGetImageFromCurrentImageContext()
I only seem to get my sublayer in the returned UIImage
that I added to my UIView
. I would like the returned UIImage
to have both the camera feed in my UIView
as well as the CALayer
sublayer I added to the UIView
.
I set up the camera feed in my UIView
, drawing my sublayer, adding my sublayer, then setting up my Context with:
UIGraphicsBeginImageContextWithOptions(myView.layer.frame.size,myView.layer.isOpaque,UIScreen.man.scale)
all in viewDidLoad()
.
Then in a later button action I try:
let img = UIGraphicsGetImageFromCurrentImageContext()
UIImageWriteToSavePhotosAlbum(img!,nil,nil,nil)
But the saved image only has my sublayer with the drawing I made and not the camera feed. Any ideas?