3

I am searching for a pixel collision with two UIImageview with transparency.

The check should be done after an UIView was dragged and it should detect if the UIView overlaps another UIImageview. With CGRectIntersectsRect only the frames are compared. Maybe there is a solution of create a new UIImageview from the overlapped area and check if there is only transparency in it?

Maybe someone has another hint or solution?

Ilmari Karonen
  • 49,047
  • 9
  • 93
  • 153
corban
  • 618
  • 6
  • 16

1 Answers1

0

You can get the intersected frame rect from CGRectIntersectsRect and extract alpha channel values of the intersected areas for both of the image as described in Retrieving a pixel alpha value for a UIImage, If both have non-zero alpha on the same position, a collision is detected.

Community
  • 1
  • 1
overboming
  • 1,502
  • 1
  • 18
  • 36