How to change UITableViewCell Image to Circle in UITableView

前端 未结 11 1492

My code works for the most part.

  • The issue I am having is the images start out as square, and change to circle when I scroll the table or refresh it.

11条回答
  •  失恋的感觉
    2021-02-12 12:40

    In case your cell is by code:

    func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
            let myImageView = (cell as! MyCustomCell).myImageView
            myImageView.layoutIfNeeded()
            myImageView.layer.cornerRadius = myImageView.frame.width / 2.0
     }
    

提交回复
热议问题