Blame view
App/createNew/CellMucChupWithDelete.swift
2.32 KB
d774f0637
|
1 2 |
import Foundation import UIKit |
1341bf603
|
3 |
import GeneralUtils |
d774f0637
|
4 5 6 |
class CellMucChupWithDelete: BaseTableViewCellUI { var tvTitle: UILabel!, btnDelete: UIImageView! |
1341bf603
|
7 |
var mucChup: ShootItem! |
d774f0637
|
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 47 48 49 50 51 52 53 |
static func registerClass(tableView: UITableView, forCellReuseIdentifier: String) { tableView.register(CellMucChupWithDelete.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: 8), stackView.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 8), stackView.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: -8), stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -8)]) tvTitle = UILabel() tvTitle.numberOfLines = 0 stackView.addArrangedSubview(tvTitle) btnDelete = UIImageView() btnDelete.contentMode = .scaleAspectFit btnDelete.isUserInteractionEnabled = true stackView.addArrangedSubview(btnDelete) btnDelete.widthAnchor.constraint(equalToConstant: 30).isActive = true btnDelete.image = #imageLiteral(resourceName:"delete_ic") let tap = UITapGestureRecognizer(target: self, action: #selector(CellMucChupWithDelete.btnDeleteClick)) btnDelete.addGestureRecognizer(tap) } func btnDeleteClick() { if let vcNhapMucChup = self.viewController as? VCNhapMucChup { vcNhapMucChup.deleteMucChup(mucChup) } } override func configCellWithData(baseObj: Any, index: Int) { super.configCellWithData(baseObj: baseObj, index: index) |
1341bf603
|
54 |
mucChup = baseObj as! ShootItem |
d774f0637
|
55 56 57 |
tvTitle.text = mucChup.name } } |