Circular UIImageView in UITableView without performance hit?

前端 未结 14 2728
失恋的感觉
失恋的感觉 2020-12-12 09:50

I have a UIImageView on each of my UITableView cells, that display a remote image (using SDWebImage). I\'ve done some QuartzCore

14条回答
  •  我在风中等你
    2020-12-12 10:12

    For circular imageview, use the below code.

    self.imageView.layer.cornerRadius = self.imageView.frame.size.width / 2;
    self.imageView.clipsToBounds = true
    

    Don't forget to change the cornerRadius in viewDidLayoutSubviews method of your UIView.

    Example:

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        self.imageView.layer.cornerRadius = self.imageView.frame.size.width / 2;
        self.imageView.clipsToBounds = true
    }
    

提交回复
热议问题