mark 分区
// MARK: - init
// MARK: - properties
// MARK: - func
// MARK: network
// MARK: handle views
// MARK: handle event
// MARK:functions
// MARK:life cycles
// MARK: lazy loads
实例
view controller
// MARK: - viewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
setUP()
}
// MARK: - properties
// MARK: - func
// MARK: handle views
///设置视图
private func setUP() {
setupNav()
setView()
registerEvent()
}
///设置nav
private func setupNav() {
title = "书籍评论"
}
private func setView() {
}
// MARK: network
///数据请求
private func loadData() {
}
// MARK: handle event
///注册事件
private func registerEvent() {
}
// MARK:functions
// MARK:life cycles
// MARK: lazy loads
}
view
// MARK: - init
override init(frame: CGRect) {
super.init(frame:frame)
setup()
registerEvent()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - properties
// MARK: - func
// MARK: network
// MARK: handle views
///设置
private func setup() {
}
// MARK: handle event
///事件
private func registerEvent() {
}
// MARK:functions
// MARK:life cycles
// MARK: lazy loads
}
tableView
class <#tableviewClass#>: UITableView,
UITableViewDelegate,
UITableViewDataSource
{
override init(frame: CGRect, style: UITableViewStyle) {
super.init(frame: frame, style: style)
setup()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
//设置
private func setup() {
self.delegate = self
self.dataSource = self
}
}
//MARK: - delegate && dataSource
extension <#tableviewClass#> {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
<#code#>
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
<#code#>
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
}
懒加载
button
///懒加载 <#button#>
private lazy var <#button#>: UIButton = {
let button = UIButton()
button.setImage(UIImage.init(named: "<#icon_shanchu#>"), for: UIControlState.normal)
button.setTitle("<#删除#>", for: UIControlState.normal)
button.titleLabel?.font = UIFont.kr_font(<#28#>)
button.setTitleColor(UIColor.<#c_0x999999#>, for: .normal)
return button
}()
imageView
///懒加载 imageView <#UIImageView#>
private lazy var <#UIImageView#>: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage.init(named: "<#T##String#>")
imageView.isUserInteractionEnabled = true
imageView.contentMode = .scaleAspectFit
return imageView
}()
label
///懒加载 <#label#>
private lazy var <#label#>: UILabel = {
let label = UILabel()
label.font = UIFont.kr_font(size: <#size#>)
label.numberOfLines = 0
label.text = <#"还可以输入350个字"#>
label.textColor = UIColor.<#color#>
label.textAlignment = .<#center#>return label
}()