//
// CommonTableViewCell.swift
// RZStop
//
// Created by 郑东喜 on 2018/4/27.
// Copyright © 2018年 Zzz. All rights reserved.
//
class CommonTableViewCell: UITableViewCell,RegisterCellFromNib {
func setUI() -> Void {
}
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: .default, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
/// 延长系统自带分割线
self.preservesSuperviewLayoutMargins = false
self.separatorInset = UIEdgeInsets.zero
self.layoutMargins = .zero
setUI()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension UITableViewCell {
func cell_addV(_ addV : UIView) {
contentView.addSubview(addV)
}
}
protocol RegisterCellFromNib {}
extension RegisterCellFromNib {
static var identifier: String { return "\(self)" }
}
extension UITableView {
func zdx_register(_ cellClass : AnyClass) {
register(cellClass.self, forCellReuseIdentifier: "\(cellClass.self)")
}
/// 从缓存池池出队已经存在的 cell
func zdx_dequeueReusableCell<T: UITableViewCell>(indexPath: IndexPath) -> T where T: RegisterCellFromNib {
return dequeueReusableCell(withIdentifier: T.identifier, for: indexPath) as! T
}
}
网友评论