Open onmyway133 opened 5 years ago
Use NSTextAttachment inside NSAttributedString
NSTextAttachment
NSAttributedString
extension UILabel { func addTrailing(image: UIImage) { let attachment = NSTextAttachment() attachment.image = image let attachmentString = NSAttributedString(attachment: attachment) let string = NSMutableAttributedString(string: self.text!, attributes: [:]) string.append(attachmentString) self.attributedText = string } }
the image parameter should be optional
@jianpx could you elaborate on that?
Use
NSTextAttachment
insideNSAttributedString