How to retrieve the coordinates of UILabel on the screen?

I have a bunch of UILabels on my screen and I want to fetch their location in the ViewController?
How can I do that? I do have created an IBOutlet of the labels but I found no methods can return the coordination.

hi @feanor,
Have you tried to get the bounds or the frame from the IBOutlet of the Labels? This should provide you with a CGRect that has the position and the dimensions of the label.


Thank you very much for your reply.
Yes, that would work for a single UILabel.
But I found that I have grouped some labels in one IBOutlet like this:
@IBOutlet var CirclesLabel: [UILabel]!

How then could I do this?

You should loop through the labels like

for label in CirclesLabels {


Thank you very much!I got the same idea~

1 Like

You are Welcome, anytime


This topic was automatically closed after 166 days. New replies are no longer allowed.