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条)