[英]Setting UIControl's frame changes view bounds but not where it can receive touches
[英]Setting a view's bounds changes the coordinates of the frame, WHY?
为什么设置UIView的bounds属性会使框架的坐标混乱? 例如:
self.view.frame = CGRectMake(10, 10, 200, 200);
CGRect b = CGRectMake(0, 0, 399, 323);
self.view.bounds = b;
我希望视图的框架为(10,10,399,323),但是坐标会得到一些奇怪的值,例如(-89.5 -51.5; 399 323)。
谢谢!
从UIView类参考:
更改边界大小会相对于其中心点扩大或缩小视图。
因此它将中心点保持在同一位置,这意味着必须调整框架的原点。
如果要调整视图的大小但将原点放在同一位置,请设置框架而不是边界。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.