01-ViewController-7.swift 786 B

1234567891011121314151617
  1. extension ViewController: UITableViewDataSource {
  2. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  3. 10
  4. }
  5. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  6. let cell = tableView.dequeueReusableCell(withIdentifier: "SampleCell", for: indexPath) as! SampleCell
  7. cell.sampleLabel.text = "Index \(indexPath.row)"
  8. let urlPrefix = "https://raw.githubusercontent.com/onevcat/Kingfisher-TestImages/master/DemoAppImage/Loading/kingfisher"
  9. let url = URL(string: "\(urlPrefix)-\(indexPath.row + 1).jpg")
  10. cell.sampleImageView.kf.setImage(with: url)
  11. cell.sampleImageView.backgroundColor = .lightGray
  12. return cell
  13. }
  14. }