I know how to get the distance between two points in swift. But I want to know how to get the distance between two anchors as a CGFloat.
For example: I want to find the distance between the
view.topAnchor
and the
button.topAnchor
on a view controller like this:
I'm guessing I will have to get a CGPoint of the anchors (then I can just find the difference between the y points of the CGPoint's). I just don't know how to do that.
Anchors are actually there to construct constraints. If you are already using them you can get the value just by using constraint.constant property. Like This,
But I think what you actually trying to achieve is,
measuring the distance like this.