UICollectionView - Autolayout with pinterest style layout

↘锁芯ラ 提交于 2019-12-23 18:18:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!