如何获得obj-c和Swift中视图的左下角坐标,即最大y坐标?
答案 0 :(得分:53)
假设您正在谈论UIView
,您可能需要查看CGGeometry
引用。
谈论'左'和y坐标没有多大意义,但例如
CGRectGetMaxY(view.frame) // will return the bottommost y coordinate of the view
CGRectGetMinX(view.frame) // will return the leftmost x coordinate of the view
等等。你明白了。
在Swift中,这可以做得更方便
view.frame.maxY // will return the bottommost y coordinate of the view
view.frame.minX // will return the leftmost x coordinate of the view
答案 1 :(得分:13)
这取决于你想要参考的坐标。如果您想在视图的超级视图中使用左下角坐标,则可以左下角显示:
左边坐标 view.frame.origin.x
和
底部坐标 view.frame.origin.y + view.frame.size.height