0

我想以最小尺寸缩放图像视图,甚至当图像视图的大小约为 5*5 或接近时,它也是难以处理的。

在此处输入图像描述

在 snapchat 中,图像(贴纸)以非常小的尺寸缩小,甚至很难改变位置和比例。

我已经实现了 Pan Pinch 和 Rotate 手势。并且还可以调整大小,但不像 snapchat。

我需要帮助来实现这一目标。非常感谢。

4

2 回答 2

1

我建议编写一个自定义类,扩展包含额外 UIImageView 的 UIView。将 PinchGestureRecognizer 挂钩到 UIView,然后使用他们的 GestureRecognizers Delgeate 方法来调整 UIImageView 的大小。这样触感不会改变。

要进一步优化它,您可以根据 UIImageView 的大小初始化 UIView 并将其缩小到某个最小值。这样感觉会更自然。否则,如果您开始“太大”,则会遇到不同的问题。

于 2016-07-06T14:45:31.807 回答
1

当你捏图像时,应用下面的代码

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];
于 2016-07-06T16:46:13.993 回答