1 year ago
#155963
Tae Hun Yu
I don't know how to set text inset into uilabel from uiimage in swift
I was written to code using NSMutableAttributedString() with UIImage() and String.
extension UILabel {
func attachImageLabel(string: String, image: UIImage?) {
let attachment = NSTextAttachment()
attachment.image = image
let attachmentString = NSAttributedString(attachment: attachment)
let attributedString = NSAttributedString(string: string)
let contentString = NSMutableAttributedString(string: "")
contentString.append(attachmentString)
contentString.append(attributedString)
self.attributedText = contentString
self.backgroundColor = .yellow
}
}
But I want to write like below picture. Text must be move to top in UILabel.
swift
uilabel
nsmutableattributedstring
0 Answers
Your Answer