I am trying to save a image over a image view with nothing in it. It does not work. Under the code below in the save()
function, drawPlace.image
is nil so I get the message "Image not found!".
var drawPlace = UIImageView()//The imageview
override func viewDidLoad() {
super.viewDidLoad()
drawPlace.layer.addSublayer(myLayer)
let myImage = UIImage(named: "bb.png")?.cgImage
myLayer.frame = CGRect(x: 0, y: 0, width: 300, height: 300)
myLayer.contents = myImage
}
func save() {
guard let selectedImage = drawPlace.image else {
print("Image not found!")
return
}
UIImageWriteToSavedPhotosAlbum(selectedImage, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
}
I have ben told I need to create a third image then save that to the photo gallery. I do not know how to do that.
Just looking to be able to save the iamgeview with the image over to the photo gallery.