CellMucChupWithCamera.swift 2.13 KB
import Foundation
import UIKit

class CellMucChupWithCamera: BaseTableViewCellUI {
    var tvTitle: UILabel!, imv: UIImageView!
    var mucChup: MucChup!

    static func registerClass(tableView: UITableView, forCellReuseIdentifier: String) {
        tableView.register(CellMucChupWithCamera.self, forCellReuseIdentifier: forCellReuseIdentifier)
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        initView()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initView()
    }

    private func initView() {
        let stackView = UIStackView()
        stackView.axis = UILayoutConstraintAxis.horizontal
        stackView.spacing = 8
        stackView.translatesAutoresizingMaskIntoConstraints = false
        self.contentView.addSubview(stackView)
        NSLayoutConstraint.activate([stackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 15),
                                     stackView.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 15),
                                     stackView.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: -15),
                                     stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -15)])
        tvTitle = UILabel()
        tvTitle.numberOfLines = 0
        stackView.addArrangedSubview(tvTitle)
        imv = UIImageView()
        imv.contentMode = .scaleAspectFit
        imv.isUserInteractionEnabled = true
        stackView.addArrangedSubview(imv)
        imv.widthAnchor.constraint(equalToConstant: 33).isActive = true
        imv.image = #imageLiteral(resourceName:"camera_black_ic")
        let tap = UITapGestureRecognizer(target: self, action: #selector(CellMucChupWithCamera.btnImvClick))
        imv.addGestureRecognizer(tap)
    }

    func btnImvClick() {
    }

    override func configCellWithData(baseObj: Any, index: Int) {
        super.configCellWithData(baseObj: baseObj, index: index)
        mucChup = baseObj as! MucChup
        tvTitle.text = mucChup.name
    }
}