setNeedsLayout、layoutIfNeeded和la

2015-12-14  本文已影响54人  奥个特曼
layoutSubviews在以下情况下会被调用:

在苹果的官方文档中强调:
You should override this method only if the autoresizing behaviors of the subviews do not offer the behavior you want.layoutSubviews, 当我们在某个类的内部调整子视图位置时,需要调用。
反过来的意思就是说:如果你想要在外部设置subviews的位置,就不要重写。

上一篇 下一篇

猜你喜欢

热点阅读