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,154
  • 18
  • 30
Dimoreno
  • 229
  • 2
  • 14

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
  • 43,583
  • 14
  • 113
  • 135