From 6dd7cab8f4808504b0e24d0641c4cedc5f51857c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 26 Jul 2019 14:46:29 -0400 Subject: [PATCH] Comments added. Further logic added for adding image attachments. --- MVMCoreUI/Atoms/Views/Label.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 5792f1c7..0dfd2ba1 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -413,15 +413,18 @@ public typealias ActionBlock = () -> Void let mutableString = NSMutableAttributedString(attributedString: attributedText) - if index != 0 { + if index == 0 { + mutableString.insert(NSAttributedString(attachment: Label.getTextAttachmentImage(dimension: font.pointSize)), at: index) + } else { mutableString.insert(NSAttributedString(string: " "), at: index) + mutableString.insert(NSAttributedString(attachment: Label.getTextAttachmentImage(dimension: font.pointSize)), at: index + 1) } - mutableString.insert(NSAttributedString(attachment: Label.getTextAttachmentImage(dimension: font.pointSize)), at: index + 1) + self.attributedText = mutableString - if index < attributedText.length { - hasAttachmentImageInsideText = true - } +// if index < attributedText.length { +// hasAttachmentImageInsideText = true +// } } static func getTextAttachmentImage(dimension: CGFloat) -> NSTextAttachment { @@ -588,6 +591,7 @@ extension UITapGestureRecognizer { func didTapAttributedTextInLabel(_ label: Label, inRange targetRange: NSRange, offset: Int) -> Bool { + // There would only ever be one clause to act on. if label.makeWholeViewClickable { return true }