我想为 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)])
可以得到圆角,但图像模糊,不清晰。像这样:
我该如何处理这个问题?
最佳答案
图像处理器的单位是像素而不是点。如果您尝试将图像设置为视网膜显示屏上的 30x30 点 ImageView (我猜您应该需要这样做),则意味着您需要将其大小至少调整为 2x,即 60x60。
如果您还瞄准 iPhone x Plus 3x 显示屏,则需要 90x90。
关于ios - 使用 Kingfisher3.1 时圆形 ImageView 模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45340786/