| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import UIKit
- import Kingfisher
- class ViewController: UIViewController {
- lazy var tableView: UITableView = {
- let tableView = UITableView(frame: .zero)
- tableView.register(SampleCell.self, forCellReuseIdentifier: "SampleCell")
- tableView.translatesAutoresizingMaskIntoConstraints = false
- tableView.rowHeight = 80
- return tableView
- }()
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view.
- print(KingfisherManager.shared)
-
- tableView.dataSource = self
- view.addSubview(tableView)
- NSLayoutConstraint.activate([
- tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
- tableView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
- tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
- tableView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)
- ])
- }
- }
- extension ViewController: UITableViewDataSource {
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- 1
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "SampleCell", for: indexPath) as! SampleCell
- cell.sampleLabel.text = "Index \(indexPath.row)"
- cell.sampleImageView.backgroundColor = .lightGray
- return cell
- }
- }
|