I have a UIImageView which has another added UIImageView on top as subview, seen below:
self.imageView.image = UIImage(named: "original_image.png")
let demoStampImage = UIImage(named: "demo_stamp.png")
let frame = CGRect(x: (UIScreen.main.bounds.width / 2) - 50, y: (UIScreen.main.bounds.height / 2) - 50, width: 100, height: 100)
let demoStampImageView = UIImageView(image: demoStampImage)
demoStampImageView.frame = frame
self.imageView.addSubview(demoStampImageView)
set in viewDidLoad and i can see it nicely on the screen. But later on, when i access this self.imageView to share it, i only see original image without subview, seen below.
@objc func shareIt() {
let imageToShare = [ self.imageView.image ] -> Here image has no subview
//Code goes on...
}
Please help me, what could be the cause and what can overcome this issue? I appreciate it all.
Adding as subview does not mean two images are merged. For this, you need to first merge two images or need to take a screenshot of this image view.
Like this taking screenshot: (Note: Image size is dependent on image view size, for the original size you need to calculate frame according to the requirement.)
Edit Or you can merge two images with the original size. Like this
See more for combine/merge 2 images: here