问题
I am currently trying to build a pinterest style layout while having a dynamic height using autolayout (trying to stay away from manual calcuations of cell heights). I am currently aiming for iOS 9 and greater. I have seen brilliant examples of how to do a dynamic layout and a pinterest layout with calculations specific for each index but not with autolayout.
Currently my thoughts are that the item would no its width, i.e. layout has x number of columns and an item could span y columns, so therefore its x * y to get the width which i can calculate during the prepare method of a custom layout but how do i then get the height?
I have seen examples of people using instances of the cell outside of those used by a datasource to calculate the height but surely this is not the best as you could potentially have a large number of different style of cells, all of which the preparelayout would need a copy of.
Would anyone be able to point me in a general direction of a tutorial or example?
来源:https://stackoverflow.com/questions/46391911/uicollectionview-autolayout-with-pinterest-style-layout