use*_*888 1 objective-c uiimageview uiimage tintcolor ios
我正在将图像加载到我的自定义单元格上的 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];
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题?
您应该使用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];
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
950 次 |
| 最近记录: |