Using a transparent UIImageView to clip other UIImageViews

425 views Asked by At

I was wondering if there is anyway to use a transparent UIImageView (Box C) to clip certain images that move overtop of it.

In my example I am moving Box A & B which are both UIImageViews towards Box C which is Transparent. Once the boxes collide I would like only Box B to be clipped.

Example http://www.demonbox.ca/Questions/QuestionExample.jpg

I know I could simply have Box C none transparent then make sure Box B is underneath and Box A is overtop of it. But for my specific purpose I don't really want to do that. I would like to keep Box C to be transparent as to show my background and anything else that might be there.

As always any help is appreciated. :)

Thanks in advance.

1

There are 1 answers

0
Chris Wagner On BEST ANSWER

Detect the collision and continually resize the UIImageView that should be clipped so that it never extends beyond/overlaps C. You will need to setup the autoresize mask so that the UIImage within your UIImageView does not scale down as the resize is occurring though.

Edit

Here is what I am trying to explain visually...

enter image description here

Full Size