Subview Clipping

Thanks to the natural pairing of the gesture recognizers and the affine transforms, we’ve added the dragging and pinch-zooming functionality that will be familiar to our users from many other apps they use. However, views that are allowed to just sprawl all over the screen aren’t something we usually see on iOS. It may be fun, but it feels wrong, and we hardly want to let the user make a mess of our user interface.

Let’s rein in the madness a little bit. We’ll put the image view into another view, and have it clipped off at that view’s edges. That will put an end to sliding the image offscreen or under the Done button.

In the storyboard, select the image view and delete it (with the Backspace key or the Edit > Cut menu item). ...

Get iOS 9 SDK Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.