【发布时间】:2016-04-06 16:00:59
【问题描述】:
让 form = UIView(frame: CGRectMake(0.0, 140.0, view.bounds.width, 196))
打印(form.bounds)
打印:(0.0, 0.0, 375.0, 196.0)
为什么 Y 原点返回 0.0?
【问题讨论】:
标签: swift
让 form = UIView(frame: CGRectMake(0.0, 140.0, view.bounds.width, 196))
打印(form.bounds)
打印:(0.0, 0.0, 375.0, 196.0)
为什么 Y 原点返回 0.0?
【问题讨论】:
标签: swift
因为您打印的是form.bounds 而不是form.frame
边界矩形总是相对于视图自己的坐标空间,而框架矩形是相对于其父视图的坐标空间。并且视图的原点始终是相对于自身的 (0,0)。
【讨论】: