//初始化
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)
}
//實現(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橫線滾動視圖的實現(xiàn)---方式二
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門挤悉,熙熙樓的掌柜王于貴愁眉苦臉地迎上來渐裸,“玉大人,你說我怎么就攤上這事装悲』杈椋” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵诀诊,是天一觀的道長洞渤。 經(jīng)常有香客問我,道長属瓣,這世上最難降的妖魔是什么载迄? 我笑而不...
- 正文 為了忘掉前任讯柔,我火速辦了婚禮,結(jié)果婚禮上护昧,老公的妹妹穿的比我還像新娘魂迄。我一直安慰自己,他們只是感情好惋耙,可當我...
- 文/花漫 我一把揭開白布捣炬。 她就那樣靜靜地躺著,像睡著了一般绽榛。 火紅的嫁衣襯著肌膚如雪湿酸。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼窝撵!你這毒婦竟也來了傀顾?” 一聲冷哼從身側(cè)響起,我...
- 正文 年R本政府宣布几晤,位于F島的核電站,受9級特大地震影響植阴,放射性物質(zhì)發(fā)生泄漏蟹瘾。R本人自食惡果不足惜章钾,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望热芹。 院中可真熱鬧,春花似錦伊脓、人聲如沸府寒。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽纯蛾。三九已至纤房,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間翻诉,已是汗流浹背炮姨。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 現(xiàn)如今的生活中手機相冊,微信朋友圈等滾動視圖無處不在,此外還有很多關(guān)于滾動視圖的APP也天天出現(xiàn)在我們的生活中,今...
- Xamarin XAML語言教程構(gòu)建ControlTemplate控件模板 控件模板ControlTemplate...
- 一、定義 定義對象間一種一對多的依賴關(guān)系夜焦,使得每當一個對象改變狀態(tài),則所有依賴于它的對象都會得到通知并被自動更新糊探。...
- 2018年4月29日髓考,星期日弃酌,巴西晴 人生如一次旅行我們遇見最美的風景 這兩句話氨菇,是大學同學寫的班歌歌詞儡炼。 那時候...