为什么设置 UIView 的 bounds 属性会弄乱它的框架坐标?
例如:
self.view.frame = CGRectMake(10, 10, 200, 200);
CGRect b = CGRectMake(0, 0, 399, 323);
self.view.bounds = b;
我希望 View 的框架为 (10, 10, 399, 323),但坐标会得到一些奇怪的值,例如 (-89.5 -51.5; 399 323)。
谢谢!
最佳答案
从 UIView 类引用:
Changing the bounds size grows or shrinks the view relative to its center point.
所以它保持中心点在同一个地方,这意味着框架的原点必须调整。
如果要调整 View 大小但将原点保持在同一位置,请设置框架而不是边界。
关于iphone - 设置 View 的边界会改变框架的坐标,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9071185/