1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // FeaturedTopicsTableViewCell.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/6/16.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- class FeaturedTopicsTableViewCell: UITableViewCell {
- class func cellWith(tableView:UITableView,indexPath:IndexPath) -> FeaturedTopicsTableViewCell {
- let ID = "FeaturedTopicsTableViewCell"
- tableView.register(FeaturedTopicsTableViewCell.self, forCellReuseIdentifier: ID)
- let cell : FeaturedTopicsTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! FeaturedTopicsTableViewCell
- cell.indexPath = indexPath
- return cell
- }
-
- override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: style, reuseIdentifier: reuseIdentifier)
- setupViews()
- setupLayouts()
- }
-
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- var indexPath: IndexPath? {
- didSet {
-
- }
- }
- //MRAK: - 设置View
- private func setupViews() {
- self.selectionStyle = .none
- addSubview(collectionView)
- }
-
- private func setupLayouts() {
- collectionView.snp_makeConstraints { (make) in
- make.top.left.right.bottom.equalToSuperview()
- }
- }
-
- private lazy var collectionView: UICollectionView = {
- let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
- collectionView.backgroundColor = .gray
- collectionView.delegate = self;
- collectionView.dataSource = self;
- collectionView.showsVerticalScrollIndicator = false
- collectionView.showsHorizontalScrollIndicator = false
- return collectionView
- }()
-
- private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
- let collectionViewLayout = UICollectionViewFlowLayout.init()
- collectionViewLayout.minimumLineSpacing = 10
- collectionViewLayout.minimumInteritemSpacing = 0
- collectionViewLayout.scrollDirection = .horizontal
- return collectionViewLayout
- }()
- }
- extension FeaturedTopicsTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
- func numberOfSections(in collectionView: UICollectionView) -> Int {
-
- return 1
- }
-
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
- return 5
- }
-
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
- let cell = FeaturedTopicsCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
- return cell
-
- }
-
- func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-
- }
-
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
- return CGSize(width:231, height: 163)
- }
-
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
- return UIEdgeInsets(top: 0, left: 14, bottom: 10, right: 14)
- }
-
- }
|