1
我想知道TouchImageView中預定義2點的最終座標。 1.如果我只是移動touchimageview,這些代碼沒問題。 2.但如果我縮放或旋轉touchimageview,ptLeft和ptRight不正確。TouchImageView在iOS中的座標變換
CGPoint ptLeft = CGPointMake (100, 100);
CGPoint ptRight = CGPointMake (200, 200);
TouchImageView *touchView = [[TouchImageView alloc] initWithFrame:rect];
....
....
/***** get the coordinate after TouchImageView has been scaled or rotated *****/
ptLeft = CGPointApplyAffineTransform(ptLeft, touchView.transform);
ptRight = CGPointApplyAffineTransform(ptRight, touchView.transform);
這裏是touchimageview源代碼 - TouchImageView source code
嗨,傑西,我還有一個問題,你能幫忙嗎?在我的程序中,我定義了一個綁定矩形,CGRect rectBound = CGRectMake(10,10,300,460);現在,如果ptLeft或ptRight移出界限,我想取消touchimageview的移動(或旋轉)。你知道該怎麼做嗎? I – user1055135
也許你可以用更多的細節創建另一個問題?對我來說最直接的解決方案是設置一個BOOL指示它超出界限,並且如果設置了BOOL,則停止旋轉。您可以使用CGRectContainsPoint進行實際測試。 –