From a2d49848225e08728cebc7c58fed02cfe356f9b9 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Sat, 27 Jul 2019 18:11:57 -0400 Subject: [PATCH] Currently investigate separate treatment for label image attachments in molecular structure. --- MVMCoreUI/Atoms/Views/Label.swift | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 2cdd6d01..69d37804 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -243,11 +243,17 @@ public typealias ActionBlock = () -> Void let imageAttachment = Label.getTextAttachmentImage(dimension: fontSize) let mutableString = NSMutableAttributedString() - if location != 0 { - mutableString.append(NSAttributedString(string: " ")) - } - mutableString.append(NSAttributedString(attachment: imageAttachment)) + let space = NSAttributedString(string: " ") + let attachment = NSAttributedString(attachment: imageAttachment) + if location == 0 { + mutableString.append(attachment) + mutableString.append(space) + } else { + mutableString.append(space) + mutableString.append(attachment) + } + attributedString.insert(mutableString, at: location) if location < attributedString.length { @@ -550,6 +556,9 @@ extension Label { guard value is NSTextAttachment else { return } attachmentLocations.append(range.location) +// if range.location == 0 { +// offset = 2 +// } } }