如何在由sd_setImageWithURL加载的单元格中将tintcolor更改为uiimage?

时间:2017-06-11 14:39:49

标签: ios objective-c uiimageview uiimage tintcolor

我正在自定义单元格中将图像加载到我的UIImageView中。这个图像是使用UIImageView + WebCache.h加载的,我想更改tintColor,但我正在尝试这段代码,但我无法改变颜色...

[cell.icon sd_setImageWithURL:[NSURL URLWithString:myURL
            placeholderImage:[UIImage imageNamed:imageName options:SDWebImageRefreshCached];
   UIImage* img = [UIImage imageNamed:imageName];
    cell.icon.image = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    cell.icon.tintColor = [UIColor yellowColor];

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

您应该使用Doc1 : {_id:1,fruits:['apple','orange','banana']} Doc2 :{_id:1,fruits:['grapes','apple','strawberry']} 功能和完成块。试试这个。

SDWebImage

答案 1 :(得分:0)

  

使用Swift 5.0,您可以使用

cell.icon.tintColor = UIColor.yellow
cell.icon.sd_setImage(with: URL(string: myURL), placeholderImage: UIImage(named: imageName), options: SDWebImageRefreshCached, completed: { image, error, cacheType, imageURL in
    cell.icon.image = image?.withRenderingMode(.alwaysTemplate)
})