iOS开源:ELWaterFallLayout-可定制瀑布流布局 UI 组件
LinVera
8年前
<h2>ELWaterFallLayout</h2> <h2>Example</h2> <p>To run the example project, clone the repo, and run pod install from the Example directory first.</p> <h2>Requirements</h2> <h2>Installation</h2> <p>ELWaterFallLayout is available through CocoaPods. To install</p> <p>it, simply add the following line to your Podfile:</p> <pre> pod "ELWaterFallLayout"</pre> <h2>Usage</h2> <pre> import ELWaterFallLayout</pre> <pre> lazy var flowLayout : ELWaterFlowLayout = ELWaterFlowLayout() collectionView = UICollectionView(frame: CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: self.view.frame.size.width, height: self.view.frame.size.height - 200)) , collectionViewLayout:flowLayout) collectionView.backgroundColor = UIColor.white collectionView.delegate = self collectionView.dataSource = self self.flowLayout.delegate = self flowLayout.lineCount = 10//十列 flowLayout.vItemSpace = 10//水平间距10 flowLayout.hItemSpace = 10//水平间距10 flowLayout.hItemSpace = 10//水平间距10 flowLayout.edge = UIEdgeInsets.zero collectionView.register(TestCollectionViewCell.self, forCellWithReuseIdentifier: "cell") self.view.addSubview(collectionView)</pre> <h3>delegate protocol</h3> <pre> func el_flowLayout(_ flowLayout: ELWaterFlowLayout, heightForRowAt index: Int) -> CGFloat { //do something for the cell height return height }</pre> <h2>Result</h2> <p style="text-align: center;"><img src="https://simg.open-open.com/show/840b1b4467a5a5fb672cddccaacc8bf9.gif"></p> <h2>Author</h2> <p><a href="/misc/goto?guid=4959738876500926655" rel="nofollow,noindex">jinqiucheng1006@live.cn</a></p> <h2>License</h2> <p>ELWaterFallLayout is available under the MIT license. See the LICENSE file for more info.</p> <p> </p> <p>来自:https://github.com/NicolasKim/ELWaterFallLayout</p> <p> </p>