Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why was the colour of image changed in iOS app?

I encountered a weird thing. The colour of my custom image was changed in the running app!
enter image description here The original colour of the alert bell image is red as shown. However, when the app runs, the colour of that bell changes to blue! enter image description here

The code to add the image is as follows:

UIImage *alertImage = [UIImage imageNamed:@"alert_bell"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:alertImage];
[imageView setBackgroundColor:[UIColor redColor]];
UIGestureRecognizer *tapGR = [[UIGestureRecognizer alloc] initWithTarget:self action:@selector(disruptionsAlertAction:)];
[self.view addGestureRecognizer:tapGR];
cell.accessoryView = imageView; // cell is a TableViewCell

I have idea what changed the colour if the bell and how to fix.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I would very much appreciate it if anyone can please explain this and let me know how I can fix it. Heaps of thanks!

>Solution :

I think you need to set the rendering mode of the image view as "UIImageRenderingModeAlwaysOriginal"

UIImage *myIcon = [[UIImage imageNamed:@"alert_bell"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImageView *myImageView = [[UIImageView alloc] initWithImage:myIcon];

This could solve your issue.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading