How get bottom y coordinate [closed]

心不动则不痛 提交于 2019-12-03 05:18:29
Gabriele Petronella

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!