【发布时间】:2023-03-19 22:20:01
【问题描述】:
我不想将比例用作经典缩放,而是想将四边形的形式更改为矩形。 经过大量尝试后,我的手指已经达到了矩形的角。 所以,但如果我在视图中开始一个新的捏合手势,我的手指会变小,而不是像正常比例那样变大。
if ([gestureRecognizer numberOfTouches] >1) {
//getting width and height between gestureCenter and one of my finger
float x = [gestureRecognizer locationInView:self].x - [gestureRecognizer locationOfTouch:0 inView:self].x;
if (x<0) {
x *= -1;
}
float y = [gestureRecognizer locationInView:self].y - [gestureRecognizer locationOfTouch:0 inView:self].y;
if (y<0) {
y *= -1;
}
//double size cause x and y is just the way from the middle to my finger
float width = x*2;
if (width < 1) {
width = 1;
}
float height = y*2;
if (height < 1) {
height = 1;
}
self.bounds = CGRectMake(self.bounds.origin.x , self.bounds.origin.y , width, height);
[gestureRecognizer setScale:1];
[[self layer] setBorderWidth:2.f];
}
有谁知道制作 X-Y-Scale 的方法,它不会将我的手指位置调整为角落。
非常感谢
【问题讨论】:
-
如果这个问题较旧,甚至有一个公认的答案,为什么还要重复?
标签: iphone objective-c scale pinch