2017-06-11 60 views
0

我正在將圖像加載到我的自定義單元格的UIImageView中。此圖像是使用的UIImageView + WebCache.h裝,我想改變tintColor,但我想這個代碼,但我不能改變顏色......如何將tintcolor更改爲由sd_setImageWithURL加載的單元格中的uiimage?

[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]; 

我怎樣才能解決這個問題?

回答

1

你應該使用SDWebImage函數完成塊。嘗試這個。

cell.icon.tintColor = [UIColor yellowColor]; 
[cell.icon sd_setImageWithURL:[NSURL URLWithString:myURL] placeholderImage:[UIImage imageNamed:imageName] options:SDWebImageRefreshCached completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {   
    cell.icon.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];    
}]; 
相關問題