开发者

How to handle exact UITouch of image?

开发者 https://www.devze.com 2023-01-14 16:42 出处:网络
I have an image for example triangle and place it inside UIImageView, and I have a touch and drag application开发者_如何转开发, I can already drag the triangle but my problem is I can still drag the t

I have an image for example triangle and place it inside UIImageView, and I have a touch and drag application开发者_如何转开发, I can already drag the triangle but my problem is I can still drag the triangle even if I'm not actually touching the triangle, (Im touching the upper left of the triangle image) I think this is because the UIImageView itself is a square so although I have not touch the triangle image but I have touch the square UIImageView that's why I can still drag it w/o touching the triangle,

So the question would be how can I make this accurate, like I can only drag it if I have touch the triangle image and not really the square ImageView?

Hopeful for all your help.


Instead of using UIButton, try using CGPath and testing for CGPathContainsPoint.

Also, try LaMarche's Improved Irregular UIButton.

Otherwise, you could use some trigonometry to determine where the touch occurred and whether or not it is within your internal shape.

0

精彩评论

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