CALayer frame.size不等于bounds.size [英] CALayer frame.size not equal to bounds.size

查看:91
本文介绍了CALayer frame.size不等于bounds.size的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CALayer上发生了一件让我感到奇怪的事情,最后发现CALayer的frame.size不等于它的bounds.size,我无法理解。我知道frame在super的坐标系中,bounds是它自己的坐标,通常情况是frame.origin不等于bounds.origin,但是frame.size等于bounds.size。

I happened to something strange to me on CALayer.And finally found the CALayer's frame.size not equal to its bounds.size, which I couldn't understand.I know frame is in the super's coordinate system and bounds is its own coordinate,and the usual case is frame.origin is not equal to bounds.origin but frame.size is equal to bounds.size.

推荐答案

这是因为您像苹果在frame属性的文档中所说的那样应用了转换。

That is because you applied a transform, as apple says on the documentation for the frame property.


警告如果transform属性为

Warning If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.

,而不是身份转换,因此该属性的
值未定义,因此应忽略。 p>

...


可以对此属性进行动画处理。但是,如果transform
属性包含一个非同一性变换,则框架
属性的值是不确定的,不应修改。在这种情况下,您
可以使用center属性重新定位视图,并使用bounds属性来调整
的大小。

Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.

http:// developer。 apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html

如果未应用转换,则


边界矩形的大小是耦合的到边框
矩形的大小,以便更改其中一个会影响另一个矩形。

The size of the bounds rectangle is coupled to the size of the frame rectangle, so that changes to one affect the other.

这篇关于CALayer frame.size不等于bounds.size的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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