1

I had to create a control which displays the image chosen by the user in a rectangular frame and also allows her to scroll and zoom it. This, I have accomplished by adding a UIImageView as a subview of a UIScrollView. Now, in a new layout, the container view has to be triangular and the portion of the image going outside the container must be cropped. The user must still be able to scroll and zoom it.

How can this be done? I have rendered static images using image masks, but can the same be used over zoomable and scrollable images? Or is there some other way to do this?

gigahari
  • 671
  • 1
  • 7
  • 19
  • [This answer](http://stackoverflow.com/a/9615445/104790) describes how to mask any view. For your use case you would apply this technique on the scroll view or a view above the scroll view. – Nikolai Ruhe Jul 30 '13 at 08:27

1 Answers1

0

The simplest way to do this is probably to make a CAShapeLayer with a path describing the desired triangle, and then setting that as the mask on your UIScrollView's layer.

ipmcc
  • 29,581
  • 5
  • 84
  • 147