You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm trying to add multiple attachments (NSTextAttachment) to the Attributed Label to looks like the attached image but it's not clickable
any way to do it?
letnumber=Atributika.Style("b").font(AppFont.getUthmanTahaBoldFont(size:16),.normal).backgroundColor(self.view.backgroundColor!,.highlighted).backgroundColor(self.view.backgroundColor!,.normal).foregroundColor(.white,.normal)letstr="<b>Running</b> with <img note=\"1\"></img> bla bla bla <img note=\"1\"></img> <b>Running</b> with <img note=\"1\"></img> bla bla bla <img note=\"1\"></img> <b>Running</b> with <img note=\"1\"></img> bla bla bla <img note=\"1\"></img> <b>Running</b> with <img note=\"1\"></img> bla bla bla <img note=\"1\"></img>".style(tags: number)letmutableAttrStr=NSMutableAttributedString(attributedString: str.attributedString)varlocationShift=0
for detection in str.detections {
switch detection.type {case.tag(let tag):
if let imageId = tag.attributes["note"]{lettextAttachment=NSTextAttachment()letimgview=FootnoteView(frame:CGRect(origin:CGPoint(x:0, y:0), size:CGSize(width:20, height:20)), number: imageId)letimage= imgview.asImage()
textAttachment.image = image
letimageAttrStr=NSAttributedString(attachment: textAttachment)letnsrange=NSRange(detection.range, in: mutableAttrStr.string)
mutableAttrStr.insert(imageAttrStr, at: nsrange.location + locationShift)
locationShift +=1}default:
break
}}
attributedLbl.numberOfLines =0letall=Atributika.Style.font(AppFont.getUthmanTahaBoldFont(size:16),.normal).backgroundColor(.pinkColor,.highlighted).backgroundColor(.pinkColor,.normal).foregroundColor(.white,.normal)
attributedLbl.attributedText = mutableAttrStr.styleAll(all)
attributedLbl.onClick ={ label, detection in
switch detection.type {case.tag(let tag):
if tag.name =="img"{letalert=UIAlertController(title:"Test", message:"Success", preferredStyle:.alert)letokAction=UIAlertAction(title:L10n.Download.lblOk, style:.cancel){(_)in}
alert.addAction(okAction)self.present(alert, animated: true)}default:
break
}}
The text was updated successfully, but these errors were encountered:
Hello,
I'm trying to add multiple attachments (NSTextAttachment) to the Attributed Label to looks like the attached image but it's not clickable
any way to do it?
The text was updated successfully, but these errors were encountered: