如何获得底部y坐标
如何获得obj-c和Swift中视图的左下坐标,即最大y坐标?
假设你在谈论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 view.frame.minY
这取决于你想要的坐标参考。 如果你想在你的视图的超视图左下angular坐标,你可以得到的左侧和底部:
view.frame.origin.x
为左边坐标
和
view.frame.origin.y + view.frame.size.height
作为底部坐标