doyeona
Published in

doyeona

How to make UIView Clickable?

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! 🌱

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Doyeon

Doyeon

Hey! I am currently studying iOS by myself, and wanna be a cool app developer 🕶 please correct me if i’m wrong or if there’s any thing that you wanna share😊✌️