1

Here is a photo explanation to better illustrate what I mean:

I have two UIImageViews, with View1 being on the bottom and View2 at the top:

enter image description here enter image description here

What I would like to do accomplish is to programmatically set an area on View2 that is completely transparent (i.e. has an alpha of 0), so that this will be the end result:

enter image description here

I haven't been able to find a similar problem related to marking a part of a UIImageView transparent in the form of a shape (specifically, a circle), and was wondering how I should tackle this problem?

Thanks!

daspianist
  • 5,336
  • 8
  • 50
  • 94

1 Answers1

1

One road you could go is CoreGraphics:

  1. Create an image context
  2. Set the clipping path you need (or just clear the circle for the "hole" after drawing)
  3. Draw the original image into the context
  4. Make an UIImage from that context
  5. Assign the image to the top UIImageView

https://developer.apple.com/library/ios/documentation/2ddrawing/conceptual/drawingprintingios/HandlingImages/Images.html#//apple_ref/doc/uid/TP40010156-CH13-SW1

iOSX
  • 1,270
  • 13
  • 18
  • Thanks for answering and the suggestion @iOSX. I'll have a look at the documentation and see if I could figure out a way to get the "hole" to work with the clipping path as suggested. – daspianist May 11 '14 at 00:53