0

what I want to do is change only the black color of my original image to another color, and keep for example white color of my image

what I have tried is:

       cell.iconeEcoute?.image =     cell.iconeEcoute?.image!.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
       cell.iconeEcoute?.tintColor = colorHexIcone

But this code change the entire image color, and I want to keep green color and replace only black color in the image

any help would be appreciated

Ketan P
  • 4,259
  • 3
  • 30
  • 36
tamtoum1987
  • 1,957
  • 3
  • 27
  • 56
  • The answer to this question should be able to help you: http://stackoverflow.com/questions/8046643/how-to-change-a-particular-color-in-an-image/32638622#32638622 – Tim Ebenezer Jul 11 '16 at 10:07
  • `UIImageRenderingMode.AlwaysTemplate` will always change the color if the alpha is 1.0. It does not matter if your color is red, black or white. Any other color that have alpha < 1.0 will be treated as transparent. – Zac Kwan Jul 11 '16 at 10:22

1 Answers1

0

You can achieve it by taking separate View. Then give different color and alpha as you want. and you will see that part in different color.

JAck
  • 854
  • 9
  • 18
  • you have a example ? i'm not sure i understand what you say – tamtoum1987 Jul 11 '16 at 11:15
  • take view as newView = UIView(frame(CGRect(size you want different in your image))) simply search on google for adding view and its property. I have example but In all cases you need different views – JAck Jul 11 '16 at 11:17
  • (size you want different in your image? , but i have more than 5 images, they dont have the same size or the same view that i want different – tamtoum1987 Jul 11 '16 at 11:32
  • is different, but i want to change only black color and keep other color – tamtoum1987 Jul 11 '16 at 11:55
  • ok.. you should try this.... take one view that covers full image and then you can set alpha with the condition that if color == black else don't change color – JAck Jul 11 '16 at 12:19