Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yoncopin

macrumors newbie
Original poster
Jul 20, 2008
2
0
My IPhone app has a subclassed UIView being added to the main view to receive touch tap and drag events. A drag moves the subclassed UIView around the window, and a tap rotates it 45 degrees. Within the subclassed UIView I have used CoreGraphics path functions to draw a simple triangle.

My problem is that I would like to detect when the touch event has occurred only within the drawn triangle. I have the CGPoint which corresponds to the touch point for the entire device coordinate system and need to translate that point to the corresponding point on my graphics context within the UIView.

Originally I implemented my own translation function, which was able to successfully hit test using CGPathContainsPoint. Unfortunately once I rotate the UIView my function's limitations are reached and it seems like I'm trying to do this the hard way. I've experimented with CGContextConvertPointToUserSpace but it's results are not what I'd expect and I haven't been able to figure out how to use it properly yet.

Any help would be greatly appreciated.
 

yoncopin

macrumors newbie
Original poster
Jul 20, 2008
2
0
Can anyone provide any insight on what the CGContextConvertPointToUserSpace and CGContextConvertPointToDeviceSpace do and how to interpret their results? I think these functions are the key to my problem, but I don't fully understand them.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.