Reputation: 2297
I want to scale imageview at minimum size and even the image view is intractable when it's size is around 5*5 or something near.
In snapchat Image (sticker) is shrinking at very small size and even it can be intractable to change position and scale.
I have implemented Pan Pinch and Rotate gesture. And also make it resizable but not as like snapchat.
I want help to achieve this. Many thanks.
Upvotes: 0
Views: 330
Reputation: 9589
When you pinch the image,apply the below code
NSData *postData = UIImageJPEGRepresentation(passYourImageHere, (double)(100-[25 doubleValue])/100);
NSInteger imgSizeBytes = [postData length];
double imgSizeKBytes = ceil((double)imgSizeBytes / 1024);
NSString *strBytes;
if(imgSizeKBytes > 1024) {
double imgSizeMBytes = (double)imgSizeKBytes / 1024;
strBytes = [NSString stringWithFormat:@"%.1f MB", imgSizeMBytes];
}
else {
strBytes = [NSString stringWithFormat:@"%d KB", (int)imgSizeKBytes];
}
imgView.image = [UIImage imageWithData:postData scale:0.1];
lblSize.text = [NSString stringWithFormat:@"The shrinked size will be%@", strBytes];
Upvotes: 1
Reputation: 3125
I'd suggest to write a custom class, extending UIView which contains an additional UIImageView. Hook the PinchGestureRecognizer to the UIView and then use their GestureRecognizers Delgeate Methods to resize the UIImageView. this way the tactility doesn't change.
to further optimize it you could initialize the UIView based on the size of the UIImageView and also scale it down to a certain minimum. That way It will feel more natural. Otherwise, if you start "too big" than you have a different issue.
Upvotes: 1