自定義了UIButton類饥臂,重寫了該類的layoutSubviews方法傻粘,但是在layoutSubviews中計算子控件布局是使用的frame屬性卫袒,然后在外部改變了transform屬性后扣唱,然后就各種被虐汞舱,算出來的子控件frame沒錯诸老,但就是顯示不正常隆夯。找了一天的bug終于發(fā)現(xiàn)了下面的一段話
*** 如果在程序中改變了某個控件的transform,那么請不要使用frame計算子控件的布局,應該使用bounds+center代替 ***
官方文檔上關于transform屬性的說明:
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.