How to make UIView Clickable?

Doyeon
doyeona
Published in
2 min readJan 13, 2021

Sometimes you want to make multiple objects in one group and make it clickable. I brought the simplest way to do it!

You can either use TapGestureRecognizer to your label, views, and many other objects or to use stackView 😈

btw, anyone Interested to read my post about TapGestureRecognizer, please click the link below.

For example, when changing the profile, i just want the user to click within the area between the image and the label to do some tasks but how to make them in one group and how will know if the object is clicked or not?

1️⃣ Add View

2️⃣ Inside the View, add Stack View and Button objects. Add the constraints top, bottom, left, right to 0 for each object.

3️⃣ Inside the stackView, add objects (image, label)

4️⃣ Run the code and click it!

Whenever clicking the label or image, it will show you an action. Thank you for reading! 🌱

--

--

Doyeon
doyeona

Passionate iOS developer creating extraordinary apps. Innovative, elegant, and collaborative. Constantly pushing boundaries.Let's build the future together📱✨🚀