How do I add a UIImage to grouped UITableViewCell so it rounds the corners?

后端 未结 5 707
囚心锁ツ
囚心锁ツ 2021-02-14 14:38

I\'m trying to add images to table cells in a grouped UITableView but the corners of the images are not clipped. What\'s the best way to go about clipping these (besides clippin

5条回答
  •  鱼传尺愫
    2021-02-14 15:10

    If you're happy to have all four image corners rounded, then you can just do the following when creating the cell:

    cell.imageView.layer.masksToBounds = YES;
    cell.imageView.layer.cornerRadius = 10.0;
    

    If you also want to inset the image from the boundary, I described a simple category on UIImage to do it here.

提交回复
热议问题