How get bottom y coordinate

Alessio Vinaccia picture Alessio Vinaccia · Jun 27, 2013 · Viewed 33.3k times · Source

How can I get the bottom left coordinate, i.e. the maximum y coordinate, of a view in obj-c and Swift?

Answer

Gabriele Petronella picture Gabriele Petronella · Jun 27, 2013

Supposing that you're talking about UIView, you may want to look at the CGGeometry reference.

Talking about 'left' and y coordinate doesn't make much sense, but for instance

CGRectGetMaxY(view.frame) // will return the bottommost y coordinate of the view
CGRectGetMinX(view.frame) // will return the leftmost x coordinate of the view

and so on. You get the idea.

In Swift, this is even more convenient, as you can do

view.frame.maxY // will return the bottommost y coordinate of the view
view.frame.minX // will return the leftmost x coordinate of the view