Chris Palmer Breuer Chris Palmer Breuer - 1 month ago 12
Swift Question

Programmatically image as UIButton but without attributes

At the moment the

looks like this:


The button images are colored icons generally and I am wondering how I can keep them that way without them changing the color.

The code I currently use simply sets the image for the

cell.iconImageButton.setImage(UIImage(named:, for: UIControlState.normal)

Any direction to the answer would be greatly appreciated! Thanks!


Use withRenderingMode with your UIImage object and set as alwaysOriginal.

cell.iconImageButton.setImage(UIImage(named:!.withRenderingMode(.alwaysOriginal), for: UIControlState.normal)