How to change UITableViewCell Image to Circle in UITableView

前端 未结 11 1484

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:37

    Try this in override-

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    
        // image Width(84) / 2 = 42
                cell.CellImage.layer.cornerRadius = 42.0
                cell.CellImage.layer.masksToBounds = true
             //or   
    
            cell.CellImage.layer.cornerRadius = cell.CellImage.frame.width / 2
            cell.CellImage.clipsToBounds = true
    }
    

提交回复
热议问题