//初始化
public var mDataList = [ReuniteMarketModel]()
// MARK: - 懶加載九宮格分類按鈕
private lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout.init()
layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 0
layout.itemSize = CGSize(width:(YYScreenWidth-20)/3, height:100)
layout.scrollDirection = .horizontal
let collectionView = UICollectionView.init(frame:.zero, collectionViewLayout: layout)
collectionView.contentSize = CGSize.init(width: YYScreenWidth-20, height: 100)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.backgroundColor = UIColor.white
collectionView.showsVerticalScrollIndicator = false
collectionView.showsHorizontalScrollIndicator = false
collectionView.register(HomeSelfSelectCell.self, forCellWithReuseIdentifier:"SelfCellIdentifier")
return collectionView
}()
self.addSubview(self.collectionView)
self.collectionView.snp.makeConstraints { (make) in
make.left.right.equalToSuperview()
make.top.equalTo(title1.snp.bottom).offset(10)
make.height.equalTo(100)
}
//實(shí)現(xiàn)代理
extension HomeHeadViewNew: UICollectionViewDataSource, UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.mDataList.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell:HomeSelfSelectCell = collectionView.dequeueReusableCell(withReuseIdentifier: "SelfCellIdentifier", for: indexPath) as! HomeSelfSelectCell
cell.backgroundColor = UIColor.white
cell.mAllMarketModel = self.mDataList[indexPath.row]
return cell
}
}
//加載數(shù)據(jù)
self.collectionView.reloadData()
//cell
class HomeSelfSelectCell: UICollectionViewCell{
override init(frame: CGRect) {
super.init(frame: frame)
setUpUI()
}
func setUpUI(){
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
var mAllMarketModel: ReuniteMarketModel? {
didSet {
}
}
}
IOS橫線滾動(dòng)視圖的實(shí)現(xiàn)---方式二
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 現(xiàn)如今的生活中手機(jī)相冊(cè),微信朋友圈等滾動(dòng)視圖無處不在,此外還有很多關(guān)于滾動(dòng)視圖的APP也天天出現(xiàn)在我們的生活中,今...
- Xamarin XAML語言教程構(gòu)建ControlTemplate控件模板 控件模板ControlTemplate...
- 一、定義 定義對(duì)象間一種一對(duì)多的依賴關(guān)系,使得每當(dāng)一個(gè)對(duì)象改變狀態(tài),則所有依賴于它的對(duì)象都會(huì)得到通知并被自動(dòng)更新。...
- 2018年4月29日,星期日,巴西晴 人生如一次旅行我們遇見最美的風(fēng)景 這兩句話,是大學(xué)同學(xué)寫的班歌歌詞。 那時(shí)候...