Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How get bottom y coordinate [closed]

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

like image 630
Alessio Vinaccia Avatar asked Jun 27 '13 00:06

Alessio Vinaccia


2 Answers

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
like image 177
Gabriele Petronella Avatar answered Nov 19 '22 09:11

Gabriele Petronella


It depends on what you want the coordinate in reference to. If you want the bottom left coordinate in your view's superview you could get the left and bottom with:

view.frame.origin.x for the left coordinate

and

view.frame.origin.y + view.frame.size.height for the bottom coordinate

like image 17
SeanT Avatar answered Nov 19 '22 09:11

SeanT