Blue image for buttons

I have buttons in my costoum cell and I am installing images from code. But something strange is happening. My images are blue.

 BOOL isTheObjectThere = [self.favoriteArry containsObject:self.tableData[indexPath.row]];
        if (isTheObjectThere==TRUE) {
            cell.favBtn.hidden = NO;
            [cell.favBtn setImage:[UIImage imageNamed:@"favorite_star.png"] forState:UIControlStateNormal];
            cell.favBtn.tag = indexPath.row;
            [cell.favBtn addTarget:self action:@selector(unfavoriteBtn:) forControlEvents:UIControlEventTouchUpInside];

enter image description here

+4
source share
1 answer

As pointed out in the comments, you should create a button with type UIButtonTypeCustom if it is currently set to UIButtonTypeSystem and you want to avoid the hue color. In addition, you can set the image rendering mode to make sure that you always get the original image, not the tinted one:

[[UIImage imageNamed:@"favorite_star.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
0
source

Source: https://habr.com/ru/post/1584288/


All Articles