我有以下代码,显示uilabel右侧的图像,目前我的uilabel的颜色是黑色但我想知道如何将图像的颜色更改为绿色
我的代码:
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
提前致谢
答案 0 :(得分:1)
尝试使用以下代码
let image = UIImage(named:"ic_premium")!
let templateImage = image.withRenderingMode(.alwaysTemplate)
templateImage.tintColor = UIColor.green
attachment.image = templateImage