123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- //
- // CommunityMyFollowTopicCell.swift
- // RainbowPlanet
- //
- // Created by Christopher on 2019/6/12.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- import RxSwift
- import RxCocoa
- class CommunityMyFollowTopicCell: UITableViewCell {
-
- let disposeBag = DisposeBag()
-
- typealias FocusClickClosure = (_ isFocusSelected: Int) -> Void
- var focusClickClosure : FocusClickClosure?
-
- class func cellWith(tableView:UITableView,indexPath:IndexPath) -> CommunityMyFollowTopicCell {
- let ID = "CommunityMyFollowTopicCell"
- tableView.register(CommunityMyFollowTopicCell.self, forCellReuseIdentifier: ID)
- let cell : CommunityMyFollowTopicCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! CommunityMyFollowTopicCell
- 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
- backgroundColor = kffffffColor
-
- addSubview(titleLabel)
- addSubview(focusButton)
- addSubview(sepView)
- }
-
- private func setupLayouts() {
- titleLabel.snp.makeConstraints { (make) in
- make.top.equalTo(20)
- make.left.equalTo(14)
- make.right.equalToSuperview().offset(-92)
- make.height.equalTo(21)
- }
- focusButton.snp.makeConstraints { (make) in
- make.top.equalTo(18)
- make.right.equalToSuperview().offset(-14)
- make.width.equalTo(64)
- make.height.equalTo(26)
- }
- sepView.snp.makeConstraints { (make) in
- make.left.equalTo(titleLabel.snp_left)
- make.right.equalTo(focusButton.snp_right)
- make.bottom.equalToSuperview()
- make.height.equalTo(1)
- }
- }
-
- private lazy var titleLabel: UILabel = {
- let titleLabel = UILabel()
- titleLabel.text = "空瓶好物合集"
- titleLabel.textColor = k333333Color
- titleLabel.font = kRegularFont15
- titleLabel.textAlignment = .left
- return titleLabel
- }()
-
- private lazy var focusButton: UIButton = {
- let focusButton = UIButton(type: UIButton.ButtonType.custom)
- focusButton.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
- focusButton.setImage(kImage(name: "common_check_icon"), for: UIControl.State.selected)
- focusButton.rx.tap.subscribe(onNext: { [weak self] (data) in
- focusButton.isSelected = !focusButton.isSelected
- if let focusClickClosure = self?.focusClickClosure {
- let isSel: Int = focusButton.isSelected == true ? 1 : 0
- focusClickClosure(isSel)
- }
- }).disposed(by: disposeBag)
-
- return focusButton
- }()
-
- private lazy var sepView: UIView = {
- let sepView = UIView()
- sepView.backgroundColor = kf5f5f5Color
- return sepView
- }()
-
- }
|