开发者

how to get touch event on specified CGRectMake

开发者 https://www.devze.com 2023-01-16 08:56 出处:网络
I want to ge开发者_如何学Got touch event on UIImageView with specified location only. UITouch *touch=[touches anyObject];

I want to ge开发者_如何学Got touch event on UIImageView with specified location only.

UITouch *touch=[touches anyObject];
CGPoint currentPoint=[touch locationInView:CGRectMake(0,0,100,100)];

CGRectMake(0,0,100,100) In the specific location i need touche event, is it possible. What to do?

Thanks in advance.


In touchesBegan and touchesMoved:

UITouch *touch=[touches anyObject];
CGPoint currentPoint=[touch locationInView:self];

CGRect testRect = CGRectMake(0,0,100,100);

if(CGRectContainsPoint(testRect, currentPoint)) {
     //For if you are touching the 100 x 100 rectangle...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消