//初始化
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)
}
//实现代理
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
}
}
//加载数据
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横线滚动视图的实现---方式二
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 现如今的生活中手机相册,微信朋友圈等滚动视图无处不在,此外还有很多关于滚动视图的APP也天天出现在我们的生活中,今...
- Xamarin XAML语言教程构建ControlTemplate控件模板 控件模板ControlTemplate...
- 2018年4月29日,星期日,巴西晴 人生如一次旅行我们遇见最美的风景 这两句话,是大学同学写的班歌歌词。 那时候...