2015-02-12 29 views
0

我使用這個代碼來旋轉圖像:旋轉時如何在旋轉過程中獲取圖像上的角落位置?

if([(UIRotationGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded) 
{ 
    currentrotation += lastRotation; 
    lastRotation = 0.0; 
    return; 
} 


    CGFloat rotation = 0.0 - (lastRotation - [(UIRotationGestureRecognizer*)sender rotation]); 
    CGAffineTransform currentTransform = imgComment.transform; 
    CGAffineTransform newTransform = CGAffineTransformRotate(currentTransform,rotation); 
    [imgComment setTransform:newTransform]; 

    lastRotation = [(UIRotationGestureRecognizer*)sender rotation]; 

無法獲取圖像視圖的位置。

現在我想要獲得圖像旋轉時ImageView角落左上角的位置。

請幫忙!!

回答

0

您需要通過應用轉換來獲取各個角的座標。根視圖的框架將是包含視圖的最小可能的矩形。 拿到一分使用的旋轉座標:

CGPoint transformedPoint = CGPointApplyAffineTransform(originalCoordinate, transform); 

原始座標是左上,右上,左下和你最初的框架矩形的右下角。

+0

什麼是originalCoordinate?不能低估..我想旋轉那個角落的按鈕。 – Sambha 2015-02-12 08:47:59

+0

無法旋轉點。 – Sambha 2015-02-12 09:51:50