Rectangle 27 0

ios How to display part of a UIView at the back of a view hierarchy in a UIView towards the front?


As I demonstrate, for example, here: stackoverflow.com/a/23452614/341994 The hole I made is a square, but in fact it can be any shape you like. And of course you can have more than one hole.

For example, this image of Venus has two square holes in it, revealing an angry-looking dude from a Stack Overflow ad behind it:

How would I add multiple masks. I need to have around 20 of these holes and when I use this method, only the last hole is punched in middleView.

It would be a lot simpler, surely, if the UIView middleView really did have holes in it. This is easily achieved with a layer mask.

Right - you only get one mask on a layer, but that mask can describe multiple holes.

So how do I do this? When I try and add holes the inverse happens and instead of cutting out holes it determines what isn't cut out.

The effect I am wanting is for the custom UIViews to make it look like the large centered UIView middleView has holes in it

Note
Rectangle 27 0

ios How to display part of a UIView at the back of a view hierarchy in a UIView towards the front?


As I demonstrate, for example, here: stackoverflow.com/a/23452614/341994 The hole I made is a square, but in fact it can be any shape you like. And of course you can have more than one hole.

For example, this image of Venus has two square holes in it, revealing an angry-looking dude from a Stack Overflow ad behind it:

How would I add multiple masks. I need to have around 20 of these holes and when I use this method, only the last hole is punched in middleView.

It would be a lot simpler, surely, if the UIView middleView really did have holes in it. This is easily achieved with a layer mask.

Right - you only get one mask on a layer, but that mask can describe multiple holes.

So how do I do this? When I try and add holes the inverse happens and instead of cutting out holes it determines what isn't cut out.

The effect I am wanting is for the custom UIViews to make it look like the large centered UIView middleView has holes in it

Note