0

I am using UITableView, and I have one UIImageView inside my UITableViewCell, so it set the cornerRadius of the UIImageView, but it doesn't work. How can I fix it?

that is my function to set the content of the cell, and I called it in tableviewdelegate of cellForRowAtIndexPath:

func setContentWithUser(#user: UserMapper) -> Void {
        
        if let avatarUrl = user.avatar{
            self.avatarImageView.layer.cornerRadius = 3
            loadImage(url: avatarUrl, { (image) -> Void in
                self.avatarImageView.image = image
            })
        }
        nameLabel.text = user.name ?? "Unknown"
        titleLabel.text = "blabla"
        hospitalLabel.text = "blabla"
        aboutLabel.text = "blabla""
}
RTzhong
  • 205
  • 1
  • 5
  • 14
  • Have you added Quartzcore framework to the project? Then only corner radius will work. – Dev Sep 09 '15 at 17:20
  • Sure I did, I use it UIView.layer.cornerRadius = 5 in other places, and that worked. But in UITableViewCell, No – RTzhong Sep 10 '15 at 01:16

1 Answers1

2

try to add this:

self.avatarImageView.cliptobounds = true
mkz
  • 2,302
  • 2
  • 30
  • 43
  • Thanks, it worked, but I don't know why it can work? – RTzhong Sep 10 '15 at 01:19
  • @RTzhong You can read more about clipToBounds [here](http://stackoverflow.com/questions/20449256/how-does-clipstobounds-work#answer-20449468). – mkz Sep 10 '15 at 07:19