I have an image view with pan and rotation gestures. pan and rotation functions as expected but at some point I have to get the image view to its initial position when changing the image. For that I'm setting the frame of image view again to the old frame. The frame is set but the image is sometimes shrunken. any help is appreciated. code for rotation is as below
@objc fileprivate func handleRotationGesture1(sender:UIRotationGestureRecognizer)
{
if sender.state == .began || sender.state == .changed {
sender.view?.transform = (sender.view?.transform.rotated(by: sender.rotation))!
sender.rotation = 0
}
}
func repositionImages()
{
imageView1.frame = imageView1Frame
imageView2.frame = imageView2Frame
imageView1.transform = CGAffineTransform.init(rotationAngle: 0)
imageView2.transform = CGAffineTransform.init(rotationAngle: 0)
imageView1.image = UIImage.init(cgImage: (image1.cgImage)!, scale: (image1.scale), orientation: .up)
imageView2.image = UIImage.init(cgImage: (image2.cgImage)!, scale: (image2.scale), orientation: .up)
}