Create Instagram’s Pinch to Zoom using Swift
Lightbox? No problem
Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 12.5, and Swift 5.4
The supporting video for this article is available at: https://youtu.be/vm6sQAN3KNU
Prerequisites:
- You will be expected to be aware how to make a Single View Application
- It would be useful to be familiar with protocol-delegate
Terminology
UIGestureRecogniser: The base class for gesture recognisers, which include tap and pinch recognisers
UIPinchGestureRecognizer: A concrete subclass of UIGestureRecogniser
The Goal
Instagram is Great!
When you scroll up and down, the images in an apparent UICollectionView
display. If you pinch an image it gets larger on the screen, and the background fades to black.
Can we somehow use a UICollectionView
to do the same?
The approach
The technique used in this implementation is to subclass a UICollectionViewCell
and if the cell itself is pinched add an overlay UIView
to UIApplication.shared.windows
(it is…