什么时候UIView的bounds.origin不会是(0,0)? [英] When would a UIView's bounds.origin not be (0, 0)?

查看:141
本文介绍了什么时候UIView的bounds.origin不会是(0,0)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么时候UIView的bounds.origin不是(0, 0)?

When would an UIView's bounds.origin not be (0, 0)?

本段对我有帮助:

重要!!边界X和Y(原点)用于在内部移动 看法.对于示例X + 5,将5pix移到帧原点的左侧 意思是将此视图中的所有内容绘制到帧的左侧5pix 起源.它本身并没有做任何事情,而是它所吸引的 会受到影响.

IMPORTANT!! Bounds X and Y, the origin, are for moving inside the View. For eample X+5, moving 5pix to the left of the frame's origin meaning draw all content within this View to the left 5pix of frame's origin. It doesn't do anything to itself, it is what being drew on it that get affected.

但是它仅描述了我自己设置bounds.origin值时的情况.
在其他情况下,bounds.origin != (0, 0)的值是什么?

But it describes only the case when I had set the value of bounds.origin myself.
In what other cases the value of bounds.origin != (0, 0)?

推荐答案

(再次编辑,因为在接受原始答案后我无法将其删除-贷记给ian,后者在下面发布了更详尽的答案:)

(edited again because I can’t delete my original answer after it was accepted—credit for this goes to ian, who posted a more thorough answer below:)

在大多数情况下,这种情况不会发生.如果您使用宽度和/或高度为负的值初始化视图,则会获得宽度为负X和/或高度为负Y的原点.

In most cases this won’t happen. If you initialize your view with a negative width and/or height, you’ll get an origin with a negative X of the width and/or negative Y of the height.

这篇关于什么时候UIView的bounds.origin不会是(0,0)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆