ios - 使用 Kingfisher3.1 时圆形 ImageView 模糊

标签 ios swift uitableview kingfisher

我想为 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)])

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

enter image description here

我该如何处理这个问题?

最佳答案

图像处理器的单位是像素而不是点。如果您尝试将图像设置为视网膜显示屏上的 30x30 点 ImageView (我猜您应该需要这样做),则意味着您需要将其大小至少调整为 2x,即 60x60。

如果您还瞄准 iPhone x Plus 3x 显示屏,则需要 90x90。

关于ios - 使用 Kingfisher3.1 时圆形 ImageView 模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45340786/

相关文章:

ios - 如何检测段 Controller 是否启用?

swift - 如何在swift中调用协议(protocol)中的默认实现代码?

swift - 按子查询 Firebase 数据

ios - 如何在两个不同部分的两个不同 NSMutableArray 的单元格中显示内容(两个标签和一个 ImageView )。

ios - swift 3 : How to use for loop for looping arrays

ios - 为什么在iOS中打开socket连接时不需要打开新线程

ios - UITableView:向上滑动时收缩标签栏和导航栏

ios - 为什么我的阵列不使用我发送给它的信息? swift 4

iphone - iphone 应用程序中的日期选择器

swift - 当用户单击通知上的 "Allow"时,FCM token 不会保存在数据库中