代码,以防止在一维中缩放和在iPhone中旋转后视图的倾斜

时间:2013-05-03 12:06:21

标签: iphone uiimage

当我在一个方向上缩放视图然后旋转该时间时图像被拉伸。 怎么预防这个? 我正在使用以下代码---

// ===按比例宽度=== //

    float scale = [self widthResizeDistance:origin toPoint:touchLocationpoint]; // [self widthResizeDistance:origin toPoint:PrevioustouchLocationpoint];
    CGAffineTransform newTransform2 = CGAffineTransformScale(self.transform, scale,1.0);
    self.transform = newTransform2;

// ===然后通过旋转=== //

    CGAffineTransform newTransform = CGAffineTransformScale(self.transform, 1, 1);
        CGFloat previousRotation = atan2(previousDifference.y, previousDifference.x);
        CGPoint currentDifference = [self vectorFromPoint:origin toPoint:touchLocationpoint];
        CGFloat currentRotation = atan2(currentDifference.y, currentDifference.x);
        CGFloat newAngle = currentRotation- previousRotation;

        newTransform = CGAffineTransformRotate(newTransform, newAngle);
        self.transform = newTransform;

0 个答案:

没有答案