如果 UILabel 中有超过 1 行文本,如何找到 UILabel 中最后一个字符的坐标?
我想在文本末尾添加图像。
我想你正在寻找NSTextAttachment
// create an NSMutableAttributedString
let fullString = NSMutableAttributedString(string: "Your text")
// create our NSTextAttachment
let imageAttachment = NSTextAttachment()
imageAttachment.image = UIImage(named: "icon")
// wrap the attachment in its own attributed string so we can append it
let imageString = NSAttributedString(attachment: imageAttachment)
// add the NSTextAttachment wrapper to our full string, then add some more text.
fullString.append(imageString)
// draw the result in a label
yourLabel.attributedText = fullString
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)