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

Deemeehaa

macrumors newbie
Original poster
Apr 18, 2014
1
0
I am having trouble accomplishing something that I thought was going to be much easier. I am trying to run a method whenever a non transparent part of a picture inside a UIImage touches another non-transparent part of an image contained within a UIImage. I have included an example to help further explain my question.

zxdOMH9.jpg


As you can see in the image above, I have two triangles that are both inside a UIImage. The triangles are both PNG pictures. Only the triangle is visible because the background has been made transparent. Both of the UIImages are inside a UIImageView. I want to be able to run a method when the visible part of the triangle touches the visible part of the other triangle. Can someone please help me?
 
If you set the image views to be UIViewContentModeScaleToFill, then you could have the UIImageViews touching each other, and the images would touch. This would only be if you know the size of the UIImages and set up your UIImageViews to be the same dimensions as the images you want to place inside of them
 
I could completely be misunderstanding what you are asking for but it sounds like you want per-pixel collision between UIImages?

i.e. you want to know when the pixels of one images collide/intersect with that of another image.

If so per-pixel collision is pretty easy to do I am sure you can find material on the internet and I think SpriteKit uses it as well. Hope this helps.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.