约束&背后的iOS算法自动版面 [英] IOS algorithm behind constraint & Auto Layout
问题描述
我正在尝试对IOS中的layoutSubviews函数进行逆向工程,在该函数中它会计算自动调整大小和约束.通常,如果我们按顺序创建约束:A依赖于(受约束的)B,B依赖于C,并且C是使用固定框架初始化的,那么系统应该足够聪明才能按以下顺序实现计算:C-> B->避免不必要的循环.
i'm trying to reverse engineer the layoutSubviews function in IOS where it calculates the autosizes and contraints. Normally, if we create constraints in orders: A depends (constrained) B, B depends C, and C was inited with a fix frame, a system should need to be smart enough to realise the calculation in order: C -> B -> A to avoid unneeded loops.
我的问题是:IOS(或算法是什么)如何遍历NSLayoutContraint列表并按此顺序计算帧?
My question is: How does IOS (or what is the algorithm) traverse the list of NSLayoutContraint and calculate the frame in such order?
推荐答案
只是在有人需要时回答:IOS使用Cassowary工具包进行自动布局( http://www.cs.washington.edu/research/constraints/cassowary/)
Just answering in case anyone needs it: IOS use Cassowary toolkit to do auto layout (http://www.cs.washington.edu/research/constraints/cassowary/)
这篇关于约束&背后的iOS算法自动版面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!