我想改变图像的色调。我想知道为什么跟随代码不起作用:
self.itemImage = [UIImageView new];
self.itemImage.contentMode = UIViewContentModeScaleAspectFit;
[_backgroundForCell addSubview:self.itemImage];
...
_itemImage.image = [UIImage imageNamed:vm.imgName];
...
self.imageView.image = [self.imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.imageView setTintColor:[UIColor redColor]];
我仍然看到这个:
答案 0 :(得分:1)
您可能忘记重命名变量:
替换
self.imageView.image = [self.imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.imageView setTintColor:[UIColor redColor]];
与
self.itemImage.image = [self.itemImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.itemImage setTintColor:[UIColor redColor]];