1

I want to know the final coordinate of predefined 2 points in TouchImageView. 1. If I just move the touchimageview, these codes are okay. 2. But if I scale or rotate touchimageview, the ptLeft and ptRight are not correct.


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);

Here is the touchimageview source code - TouchImageView source code

4

1 に答える 1

1

UIView メソッドの convertPoint:fromView: または convertPoint:toView: を使用します。何かのようなもの:

ptLeft = [touchView convertPoint:ptLeft toView:[touchView superview]];

(後者の引数は、ポイントを入れたいビューにする必要があります。スーパービューでそれを取得しようとしているように見えますが、代わりにself.viewornilまたは何か他のものを使用したい場合があります。)

于 2011-11-19T16:23:54.800 に答える