简体   繁体   中英

Grid-based UICollectionView on iOS 8 (Swift)

I'm trying to implement a UICollectionView that's grid-based, so that it looks something like this where every box is either a square or a rectangle. The number of items per row and the dimensions of each cell would differ based on screen size (ie iPhone 4, 5S, 6, iPad, etc.). This can be done using JavaScript: http://packery.metafizzy.co/ but I'd like to figure out how to do it using Swift. This would only need to work with iOS 8+ so I'm not sure if the native UICollectionView can do this already. Should I be implementing UICollectionViewFlowLayout ?

在此处输入图片说明

No native Layouts will not provide this functionality.You have to extend UICollectionViewLayout and make custom Layout based on that

You can look this example and this example .It will help you.However it is in objective-c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM