In Swift, how to get the y-position of the source text in UILabel?

I am trying to get the exact source text of a UILabel text.

label.frame.maxY returns max y fields UILabel.

But what I really want is the maxY position of the text .

Ignore the "button". I was just looking for this image from Google. I know how to get what the first returns (maxY), but I want to know how to get the second (where the dashline is under the text).

enter image description here

Thanks for any help!

+6
source share
1 answer

You can achieve this quite simply:

 let baselineY = label.frame.origin.y + label.font.ascender; 
+7
source

Source: https://habr.com/ru/post/1014624/