check size of UIImageView is smaller than original when pinching
-
27-10-2019 - |
Question
so I've loaded up an UIImageView and had a a PinchGestureRecognizer in it, the question now is how do I detect if the UIImageView size is smaller than the original size (before it was pinched)? The way I do it now is this:
- (IBAction)resizeImage:(UIPinchGestureRecognizer *)sender
{
UIImageView * imgView = (UIImageView *)[fullSizeImageView.subviews objectAtIndex:0];
sender.view.transform = CGAffineTransformScale(sender.view.transform, sender.scale, sender.scale);
NSLog(@"SCALE IS %f WITH STATE %d", sender.scale, sender.state);
if (imgView.frame.size.width < oriWidth && imgView.frame.size.height < oriHeight) {
//then it's size is smaller than original
}
}
I wonder if there's a better way to do this?
Solution
Since you're just scaling the UIImageView based on the scale of the UIPinchGestureRecognizer, wouldn't a scale value < 1.0 mean that the UIImageView is smaller than it originally was?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow