1

I have the following code which shows an image on the right side of a uilabel, currently the color of my uilabel is black but I would like to know how I change the color of my image to green

my code:

let image:UIImage=UIImage(named:"ic_premium")!
let attachment = NSTextAttachment()
attachment.image=image
attachment.bounds = CGRect(x: 0, y: -3, width: 15, height: 15)
let attributedString = NSMutableAttributedString(string: item_empresa[indexPath.item].nombre_emp!)
attributedString.append(NSAttributedString(attachment: attachment))
cell.lbl_nombreEmpresa.attributedText = attributedString

thanks in advance

R. Mohan
  • 2,182
  • 17
  • 30
Dimoreno
  • 227
  • 3
  • 15

1 Answers1

1

Try with below code

let image = UIImage(named:"ic_premium")!
let templateImage = image.withRenderingMode(.alwaysTemplate)
templateImage.tintColor = UIColor.green
attachment.image = templateImage
iPatel
  • 46,010
  • 16
  • 115
  • 137