CellChonMucChup.swift
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
}
}
}