FS.O5 FS.O5 - 1 year ago 77
Objective-C Question

Calculate where text starts on centre alignment

I have a

that I want to add a
exactly where the text starts.

The problem is that the text in the label is aligned to the centre so I don't know how to determinate where the actual text starts and where to position this

Any idea how can I calculate this thing?

Thank you!

Answer Source

You could also use


to automatically resize your label for the space it needs. And then read out the frame of your label with:

yourLabel.frame.size (width or height)