Ios 在swift 3中更改图标位置

Ios 在swift 3中更改图标位置,ios,swift,nsattributedstring,Ios,Swift,Nsattributedstring,我有以下代码在uilabel的左侧显示图标,我的问题是如何将图标放置在uilabel的右侧: let attachment = NSTextAttachment() attachment.image = UIImage(named: "ic_person") attachment.bounds = CGRect(x: 0, y: -3, width: 15, height: 15) let attachmentStr = NSAttributedString(attachment: attach

我有以下代码在uilabel的左侧显示图标,我的问题是如何将图标放置在uilabel的右侧:

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

提前感谢

您可以在附加文本之后再附加附件,将图像放在文本之后

let attachment = NSTextAttachment()
attachment.image = UIImage(named: "ic_person")
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

我的朋友,我该如何更改图像的颜色?@DiegoIsraelMoreno我在上为您创建了此UIImage扩展名,只需添加文件并像这样使用它
图像。使用(颜色:)时使用(白色)
调用“with(颜色:)”时出现此警告结果无效您是从GitHub firstYes添加了名为UIImage.swift的文件吗