一直觉得自己写的不是技术,而是情怀,一个个的教程是自己这一路走来的痕迹。靠专业技能的成功是最具可复制性的,希望我的这条路能让你们少走弯路,希望我能帮你们抹去知识的蒙尘,希望我能帮你们理清知识的脉络,希望未来技术之巅上有你们也有我。
import UIKit
class ViewController: UIViewController {
let tableView = UITableView()
let arr = ["广告1","广告2","广告3"]
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.white
view.addSubview(tableView)
tableView.backgroundColor = UIColor.white
tableView.showsVerticalScrollIndicator = false
tableView.showsHorizontalScrollIndicator = false
tableView.delegate = self
tableView.dataSource = self
tableView.separatorStyle = .none
tableView.rowHeight = 44
tableView.register(HomeNewsCell.self, forCellReuseIdentifier: "kHomeNewsCell")
tableView.snp.makeConstraints { (make) in
make.center.equalToSuperview()
make.width.equalTo(200)
make.height.equalTo(44)
}
}
}
extension ViewController: UITableViewDelegate,UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: HomeNewsCell = tableView.dequeueReusableCell(withIdentifier: "kHomeNewsCell") as! HomeNewsCell
cell.model = arr
return cell
}
}