import Foundation import UIKit import GeneralUtils class CellChonMucChup: BaseTableViewCellUI { var tvTitle: UILabel! var mucChup: ShootItem! static func registerClass(tableView: UITableView, forCellReuseIdentifier: String) { tableView.register(CellChonMucChup.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() { tvTitle = UILabel() tvTitle.translatesAutoresizingMaskIntoConstraints = false tvTitle.numberOfLines = 0 self.contentView.addSubview(tvTitle) NSLayoutConstraint.activate([tvTitle.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8), tvTitle.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 8), tvTitle.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: -8), tvTitle.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -8)]) } override func configCellWithData(baseObj: Any, index: Int) { super.configCellWithData(baseObj: baseObj, index: index) mucChup = baseObj as! ShootItem tvTitle.text = mucChup.name if mucChup.willShoot == 1 { self.contentView.backgroundColor = UIColor(hexString: "#1C9CF6") } else { self.contentView.backgroundColor = UIColor.white } } }