0

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.

enter image description here

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.

Chetan Prajapati
  • 2,249
  • 19
  • 24

2 Answers2

1

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.

samsam
  • 3,125
  • 24
  • 40
  • Yes @samsam i already done that way. and added pinch on uiview and uiimageview too. and uiview is transparent and its min and max scale is defined. when uiimageview smaller than uiview then uiview's pinch is calling. That's fine and working perfectly. BUT issue is after leaving fingers and again pinching the UIimageview is scaled to uiviews frame and again going to small. So i never able make is small as like snapchat. :( – Chetan Prajapati Jul 07 '16 at 04:21
1

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];
user3182143
  • 9,459
  • 3
  • 32
  • 39