How to change UITableViewCell Image to Circle in UITableView

前端 未结 11 1703

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

    I had a similar issue, my UIImageView was initially a square and would only show as circular when the UITableViewCell it was within was either highlighted or selected.

    It was a simple fix:

    Swift 2.0

    imgView.layer.cornerRadius = imgView.frame.width / 2
    imgView.clipsToBounds = true
    

    This was placed inside the awakeFromNib() for my custom UITableViewCell.

    This is assuming imgView is the name of the UIImageView hooked up via storyboard inside this custom UITableViewCell.

提交回复
热议问题