如何使用PINRemoteImage设置色调颜色?

时间:2019-02-17 19:24:30

标签: uiimageview uicolor

在尝试使用PINRemoteImage下载图像后,我尝试按照以下步骤设置图像的色彩,但是它不起作用。如何使用PINRemoteImage设置图像的色调颜色?

let imageView = UIImageView()
imageView.pin_setImage(from: URL(string: "https://pinterest.com/kitten.jpg")!)
imageView.tintColor = UIColor.red

1 个答案:

答案 0 :(得分:0)

此方法有效,必须在下载图像后设置图像渲染模型,方法是使用此方法PINRemoteImageManagerImageCompletion传入imageView.pin_setImage(from: URL?, completion: PINRemoteImageManagerImageCompletion?)回调

imageView.pin_setImage(from: "https://pinterest.com/kitten.jpg") { result in
    result.image?.withRenderingMode(.alwaysTemplate)
    imageView.image = result.image?.withRenderingMode(.alwaysTemplate)
}
imageView.tintColor = UIColor.red