渲染模式不起作用的图像

时间:2016-09-17 17:53:41

标签: ios objective-c uiimageview

我想改变图像的色调。我想知道为什么跟随代码不起作用:

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

我仍然看到这个:

enter image description here

1 个答案:

答案 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]];