123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- //
- // PublishSelTopicCollectionCell.swift
- // RainbowPlanet
- //
- // Created by Christopher on 2019/6/17.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- // 话题类别のCell
- import UIKit
- import RxSwift
- class PublishSelTopicCollectionCell: UICollectionViewCell {
-
- let disposeBag = DisposeBag()
-
- var subTopicModel: CommunityTopicDataModel? {
- didSet {
- titleLabel.text = self.subTopicModel?.name
- }
- }
-
- typealias DeleteClosure = (_ index: Int) -> Void
- var deleteClosure : DeleteClosure?
-
- class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> PublishSelTopicCollectionCell {
- let ID = "PublishSelTopicCollectionCell"
- collectionView.register(PublishSelTopicCollectionCell.self, forCellWithReuseIdentifier: ID)
- let cell : PublishSelTopicCollectionCell = collectionView.dequeueReusableCell(withReuseIdentifier: ID, for: indexPath) as! PublishSelTopicCollectionCell
- cell.indexPath = indexPath
- return cell
- }
- //MARK: - indexPath
- var indexPath: IndexPath?{
- didSet {
-
- }
- }
- //MARK: - 初始化
- override init(frame: CGRect) {
- super.init(frame: frame)
- backgroundColor = kffffffColor
- cornerRadius = 12
- masksToBounds = true
- setupViews()
- setupLayouts()
- }
-
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- //MRAK: - 设置View
- private func setupViews() {
- addSubview(iconImageView)
- addSubview(titleLabel)
- addSubview(deleteButton)
- }
-
- private func setupLayouts() {
- iconImageView.snp.makeConstraints { (make) in
- make.top.equalTo(5)
- make.left.equalTo(6)
- make.size.equalTo(16)
- }
- titleLabel.snp.makeConstraints { (make) in
- make.top.equalTo(3)
- make.left.equalTo(iconImageView.snp_right).offset(5)
- make.right.equalTo(-26)
- make.height.equalTo(19)
- }
- deleteButton.snp.makeConstraints { (make) in
- make.left.equalTo(titleLabel.snp_right).offset(2)
- make.right.equalTo(-2)
- make.size.equalTo(22)
- }
- }
-
- private lazy var iconImageView: UIImageView = {
- let iconImageView = UIImageView()
- iconImageView.image = kImage(name: "edit_ico_topic_pre")
- return iconImageView
- }()
-
- private lazy var titleLabel: UILabel = {
- let titleLabel = UILabel()
- titleLabel.textColor = k666666Color
- titleLabel.font = kRegularFont13
- titleLabel.textAlignment = .left
- return titleLabel
- }()
-
- private lazy var deleteButton: UIButton = {
- let deleteButton = UIButton(type: UIButton.ButtonType.custom)
- deleteButton.setImage(kImage(name: "edit_topic_delete"), for: UIControl.State.normal)
- deleteButton.rx.tap.subscribe(onNext: { (data) in
- if let deleteClosure = self.deleteClosure {
- deleteClosure(self.indexPath!.row)
- }
- }).disposed(by: disposeBag)
- return deleteButton
- }()
-
- }
|