Swift-UICollectionView基本使用

Swift-UICollectionView基本使用

2023年7月14日发(作者:)

Swift-UICollectionView基本使⽤import UIKitclass CollectionViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {

var collectionView : UICollectionView! = nil

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

return 28 }

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

let cell = eReusableCell(withReuseIdentifier: "cellID", for: indexPath) oundColor =

return cell } override func viewDidLoad() { dLoad() // Do any additional setup after loading the view. = "collectionView"

setupUI() }

private func setupUI() {

let layout = UICollectionViewFlowLayout() ze = CGSize(width: kSCREEN_W / 4, height: kSCREEN_W / 4)

tionView = UICollectionView(frame:, collectionViewLayout: layout) oundColor = urce = self te = self er(, forCellWithReuseIdentifier: "cellID") .addSubview(collectionView) } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using ation. // Pass the selected object to the new view controller. } */}

发布者:admin,转转请注明出处:http://www.yc00.com/web/1689264526a226425.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信