1

This interface has two UIButtons and each one has an emoji. Because I can't afford graphics right now and that's what we're using.

enter image description here

For normal images, I am able to tint using this code, thanks to https://stackoverflow.com/a/24979595/300224

let button = UIButton(type: .Custom)
let image = UIImage(named: "image_name")?.imageWithRenderingMode(.AlwaysTemplate)
button.setImage(image, forState: .Normal)
button.tintColor = UIColor.redColor()

However that does not work (of course in this situation since there is no UIImage.

Is there any approach I can use in this situation to tint the button?

Community
  • 1
  • 1
William Entriken
  • 37,208
  • 23
  • 149
  • 195
  • 1
    [Create an image from the string](http://stackoverflow.com/questions/38809425/convert-apple-emoji-string-to-uiimage) then tint the image as you know how. – rmaddy Feb 25 '17 at 03:13
  • There are plenty of open source assets available for you to use, especially for such common/generic items as microphones and speakers. – Alexander Feb 25 '17 at 03:19
  • @Alexander I agree with you, I am not sure what the point is to try tint some simple basic icons when this apparantly isn't a graphic manipulation app that needs to. –  Feb 25 '17 at 03:22

1 Answers1

2

You can not change the color of the example images you provide in the way you think, as the tintColor method you are thinking of will "paint over" all your existing pixels, you will only have a flat shape with your color.

However, there are custom manipulations that can be done, and you can play around with Cor eImage Filters to achieve some form of effect that suits your needs if possible.

Related:

To convert your Emoji to UIImage

Above answers the question in the title provided. In your case:

Because I can't afford graphics right now and that's what we're using.

There are no solutions.

Community
  • 1
  • 1