requiresConstraintBasedLayout <iOS>

409 阅读1分钟

今天在学习masonry框架的时候,看到第二个demo,Update View.

其中有个方法是:+ (BOOL)requiresConstraintBasedLayout.

这个方法的意思是: 如果你在- (void)updateConstraints这个方法里面给自定义的控件更新控件的constraint,那么需要重写+ (BOOL)requiresConstraintBasedLayout方法,并且返回YES.否则的话,就不会显示该控件.

如果直接在init方法中设置自定义控件的constraint,那么则不需要重写+ (BOOL)requiresConstraintBasedLayout方法,也可以显示