Question

I am getting some problem finding crop area for rectangle added as subview on imageview.

Why to add a rectangle over imageview, because I have a requirement that the cropping rectangle should be zoomed with the image. So I did the following..

UIView *rectangle;

[self.imageView addSubview:rectangle];

Then adding

UIPinchGestureRecognizer *pinchGesture=[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGesture:)];
    [self.imageView addGestureRecognizer:pinchGesture];

On gesture selector for zoom I have added.

-(IBAction)pinchGesture:(UIPinchGestureRecognizer *)recognizer{

    recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);

    recognizer.scale = 1;

}

Since the rectangle is on the imageview, it gets zoomed with the imageview.

My problem is how to get the rectangle frame used for cropping, as when I zoom imageview, it changes its frame.

Any help, or hint will be appreciated.

Thanks.

Was it helpful?

Solution

Firstly i guess you should not use rectangle as a subview to the image view, although you know the rect area that need to be cropped Rectangle image is just for the reference for the user of the application.. right ?

Refer this link

It Might help you.

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top