视图的框架和视图的边界之间的区别iPhone
我想知道 UIView 的“frame”和“bound”属性有什么区别。我使用这两个属性得到相同的结果。我无法弄清楚两者之间的区别..
提前谢谢。
I want to know what is the difference between 'frame' and 'bound' property of UIView. I get the same results using both properties. I can not figure out the difference between the two..
Thanx in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
框架是视图在其超级视图中的位置,使用超级视图的坐标系。
边界是视图在其自身坐标系中的位置和大小。
如果两个属性得到相同的结果,则意味着视图填充了其父视图,并且两个视图都以 (0, 0) 作为原点。尝试更改框架,您将看到它在其超级视图中移动到不同的位置。
The frame is the view's location in its superview, using the superview's coordinate system.
The bounds is the view's location and size in its own coordinate system.
If you are getting the same results for both properties, it means that the view fills its superview, and both views have (0, 0) as the origin. Try changing the frame, and you will see it move to different positions within its superview.
这是文档中介绍的 。框架和边界是两个不同的坐标系。
This is covered in the documentation. The frame and bounds are two different coordinate systems.
我知道为时已晚,但由于这是一个常见问题,所以我发布了 链接到苹果文档对此有详细说明
I know its too late but as this a common question so I am posting a link to apple documentation to have a detailed explanation on this