My code right now has a image overlay the photo in image picker. The problem is that the layer over the image is not being saved over the photo. It is just being displayed when the user is in the camera mode. How can I save the image on top of the photo taken.
@IBOutlet weak var imageTake: UIImageView!
func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
if let error = error {
// we got back an error!
let ac = UIAlertController(title: "Save error", message: error.localizedDescription, preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "OK", style: .default))
present(ac, animated: true)
} else {
let ac = UIAlertController(title: "Saved!", message: "Your altered image has been saved to your photos.", preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "OK", style: .default))
present(ac, animated: true)
}
}
@IBAction func takePhoto(_ sender: UIButton) {
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .camera
present(imagePicker, animated: true, completion: nil)
let mainView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height-150))
let frame = CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: 120)
let blockView = UIImageView.init(frame: frame)
blockView.contentMode = .scaleAspectFit
blockView.image = UIImage(named: "sdf")
mainView.addSubview(blockView)
imagePicker.cameraOverlayView = mainView
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
imagePicker.dismiss(animated: true, completion: nil)
imageTake.image = info[UIImagePickerControllerOriginalImage] as? UIImage
}
}