Pass Parameters in Tap Gestures

Also known as stop casting / stop using tags

Steven Curtis
3 min readNov 10, 2021
Photo by Diane Picchiottino on Unsplash

Before we start

Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 13.0, and Swift 5.3

Prerequisites

The video

This project

The answer

If you’ve several UIView instances in a view and wish to easily identify which is in a UIViewController. So the end result look something like the following:

Isn’t that nice! There are three different views here and we would like to differentiate between each one when the user taps them. Surely this is an easy task?

Now remember, there isn’t any MVVM or great architecture here so I’ve crammed everything into the ViewController — this article is about the Gestures rather than anything else!

--

--

No responses yet