0

我想为 userAvatarImageView 做一个圆角。起初,我使用了 UIImageView 的常用方法:

extension UIImageView {
    func makeRoundedCorners(_ radius: CGFloat) {
         self.layer.cornerRadius = radius
         self.layer.masksToBounds = true
   }
}

这对我有用。但我不认为这对tableViewCell 来说是一个好方法。所以,我使用了 RoundCornerImageProcessor:

let roundProcessor = RoundCornerImageProcessor(cornerRadius: 15,
                                               targetSize: CGSize(width: 30, height: 30))

userAvatarImageView.kf.setImage(with: URL(string: string),
                                    placeholder: UIImage(named: "placeholder"),
                                    options: [ .processor(roundProcessor)])

它可以得到一个圆角,但图像模糊,不清晰。像这样:

在此处输入图像描述

我该如何处理这个问题?

4

1 回答 1

0

The unit of image processor is pixel instead of point. If you are trying to set the image to a 30x30 point image view on a retina display (I guess you should need so), it means you need to resize it to 2x at least, which means 60x60.

And if you are also targeting an iPhone x Plus 3x display, you need 90x90.

于 2018-12-19T04:00:16.167 回答