I have an UIImageView that fits the size of the screen:
imageView.contentMode = .scaleAspectFill
self.view.addSubview(imageView)
imageView.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
imageView.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true
imageView.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true
imageView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
And inside that imageView I have an image:
imageView.image = UIImage(named: "pizza")
At a certain position within the imageView's bounds I want to extract what's inside a part of the pizza and send that extracted part to another UIView.
For example:
let extractionPointX = 0 //imageView.bounds.orgin.x == 0
let extractionPointY = 50 //imageView.bounds.orgin.y == 50
let extractionHeight = 100 //area's height is == 100
let extractionWidth = imageView.frame.size.width
let myExtractedImage = //the corrdinates from above
So now that I have that x, y, height, and width of whatever that area is on the picture of the pizza, I can now take that and add it to another UIView.
anotherView.addSubview(myExtractedImage)
or
anotherImageView.image = UIImage(named: "myExtractedImage")
I don't care about what happens to the image of the pizza afterwards because I'm going to set the imageView's image to nil once I get the area I need extracted from it. It can be the actual area of the pizza cut out as a UIView or or a separate image of that area (like a snapshot) of it.
How would I do this?